Address review comment from bug 551982. r=benjamn
authorDan Witte <dwitte@mozilla.com>
Wed, 05 May 2010 12:01:28 -0700
changeset 41981 eaaba443d9a95656ab2cd937dbbf32529f4ef556
parent 41980 b1b49afd8147a2aa7a7ca802b8016edbc1eefe12
child 41982 0ef9446e838c6966ac2ecf6c67b9c5a2c95a4339
push idunknown
push userunknown
push dateunknown
reviewersbenjamn
bugs551982
milestone1.9.3a5pre
Address review comment from bug 551982. r=benjamn
js/src/ctypes/CTypes.cpp
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -3939,28 +3939,28 @@ StructType::DefineInternal(JSContext* cx
     return JS_FALSE;
   js::AutoValueRooter protoroot(cx, prototype);
 
   if (!JS_DefineProperty(cx, prototype, "constructor", OBJECT_TO_JSVAL(typeObj),
          NULL, NULL, JSPROP_READONLY | JSPROP_PERMANENT))
     return JS_FALSE;
 
   // Create a hash of FieldInfo objects to stash on the type object.
-  FieldInfoHash* fields(new FieldInfoHash);
+  AutoPtr<FieldInfoHash> fields(new FieldInfoHash);
   if (!fields || !fields->init(len)) {
-    delete fields;
     JS_ReportOutOfMemory(cx);
     return JS_FALSE;
   }
 
   // Stash the FieldInfo hash in a reserved slot now, for GC safety of its
   // constituents.
   if (!JS_SetReservedSlot(cx, typeObj, SLOT_FIELDINFO,
-         PRIVATE_TO_JSVAL(fields)))
+         PRIVATE_TO_JSVAL(fields.get())))
     return JS_FALSE;
+  fields.forget();
 
   // Process the field types.
   size_t structSize, structAlign;
   if (len != 0) {
     structSize = 0;
     structAlign = 0;
 
     for (jsuint i = 0; i < len; ++i) {