diff --git a/content/html/content/src/nsHTMLCanvasElement.cpp b/content/html/content/src/nsHTMLCanvasElement.cpp
index bc7fed164716..92919ea305e4 100644
--- a/content/html/content/src/nsHTMLCanvasElement.cpp
+++ b/content/html/content/src/nsHTMLCanvasElement.cpp
@@ -581,18 +581,21 @@ nsHTMLCanvasElement::UpdateContext(nsIPropertyBag *aNewContextOptions)
rv = mCurrentContext->SetIsOpaque(GetIsOpaque());
if (NS_FAILED(rv)) {
mCurrentContext = nsnull;
+ mCurrentContextId.AssignLiteral("");
return rv;
}
rv = mCurrentContext->SetContextOptions(aNewContextOptions);
if (NS_FAILED(rv)) {
mCurrentContext = nsnull;
+ mCurrentContextId.AssignLiteral("");
return rv;
}
rv = mCurrentContext->SetDimensions(sz.width, sz.height);
if (NS_FAILED(rv)) {
mCurrentContext = nsnull;
+ mCurrentContextId.AssignLiteral("");
return rv;
}