Bug 951082 - Make nsReferencedElement::Reset fail if its call to nsContentUtils::ConvertStringFromEncoding fails. r=dholbert
authorJonathan Watt <jwatt@jwatt.org>
Fri, 06 May 2016 14:21:12 +0100
changeset 336466 8c85bfdc54424712869b6e62b3ff3c1477dacabe
parent 336464 403912ca555eb65f814b18ecf38ad8e8e98569f5
child 336467 8eef6c268b9dcee36b7f42b48bae61a747a60545
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs951082
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 951082 - Make nsReferencedElement::Reset fail if its call to nsContentUtils::ConvertStringFromEncoding fails. r=dholbert
dom/base/nsReferencedElement.cpp
--- a/dom/base/nsReferencedElement.cpp
+++ b/dom/base/nsReferencedElement.cpp
@@ -32,24 +32,19 @@ nsReferencedElement::Reset(nsIContent* a
   NS_UnescapeURL(refPart);
 
   nsAutoCString charset;
   aURI->GetOriginCharset(charset);
   nsAutoString ref;
   nsresult rv = nsContentUtils::ConvertStringFromEncoding(charset,
                                                           refPart,
                                                           ref);
-  if (NS_FAILED(rv)) {
-    // XXX Eww. If fallible malloc failed, using a conversion method that
-    // assumes UTF-8 and doesn't handle UTF-8 errors.
-    // https://bugzilla.mozilla.org/show_bug.cgi?id=951082
-    CopyUTF8toUTF16(refPart, ref);
+  if (NS_FAILED(rv) || ref.IsEmpty()) {
+    return;
   }
-  if (ref.IsEmpty())
-    return;
 
   // Get the current document
   nsIDocument *doc = aFromContent->OwnerDoc();
   if (!doc)
     return;
 
   nsIContent* bindingParent = aFromContent->GetBindingParent();
   if (bindingParent) {