Bug 1070764 - Don't try to use the uninitialized temp value while default-constructing a dictionary with a required member. r=khuey, a=lmandel
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 24 Sep 2014 09:11:30 -0400
changeset 225435 88508b8c57ce608e51c677d904d763f8dc6b131b
parent 225434 a14a70a146202adbedd381eac3603c7b1760e7b9
child 225436 27ac8a26be7d0be628de7fa95ad1d0b8b53038c5
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, lmandel
bugs1070764
milestone34.0a2
Bug 1070764 - Don't try to use the uninitialized temp value while default-constructing a dictionary with a required member. r=khuey, a=lmandel
dom/bindings/Codegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -11476,24 +11476,27 @@ class CGDictionary(CGThing):
                       "}\n")
         if member.defaultValue:
             conversion += "${convert}"
         elif not conversionInfo.dealWithOptional:
             # We're required, but have no default value.  Make sure
             # that we throw if we have no value provided.
             conversion += dedent(
                 """
-                // Skip the undefined check if we have no cx.  In that
-                // situation the caller is default-constructing us and we'll
-                // just assume they know what they're doing.
-                if (cx && (isNull || temp->isUndefined())) {
+                if (!isNull && !temp->isUndefined()) {
+                ${convert}
+                } else if (cx) {
+                  // Don't error out if we have no cx.  In that
+                  // situation the caller is default-constructing us and we'll
+                  // just assume they know what they're doing.
                   return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
                                            "%s");
                 }
-                ${convert}""" % self.getMemberSourceDescription(member))
+                """ % self.getMemberSourceDescription(member))
+            conversionReplacements["convert"] = indent(conversionReplacements["convert"]).rstrip();
         else:
             conversion += (
                 "if (!isNull && !temp->isUndefined()) {\n"
                 "  ${prop}.Construct();\n"
                 "${convert}"
                 "}\n")
             conversionReplacements["convert"] = indent(conversionReplacements["convert"])