Bug 729584 - mozJSComponentLoader::ImportInto needs to wrap exceptions (r=bholley)
authorLuke Wagner <luke@mozilla.com>
Thu, 23 Feb 2012 13:50:01 -0800
changeset 87580 a180e202f229c64ee57c1777dc7d3be13d7b3c71
parent 87579 b638c0deeafa9b8785dc74dd4a4b38f1580abc73
child 87581 24bfdb22d2d4937dafc5dc40f7ca6219df18d176
push id22133
push usermak77@bonardo.net
push dateFri, 24 Feb 2012 10:23:30 +0000
treeherdermozilla-central@fbcdc2c87df8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs729584
milestone13.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 729584 - mozJSComponentLoader::ImportInto needs to wrap exceptions (r=bholley)
js/xpconnect/loader/mozJSComponentLoader.cpp
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -1159,29 +1159,31 @@ mozJSComponentLoader::ImportInto(const n
 
     ModuleEntry* mod;
     nsAutoPtr<ModuleEntry> newEntry;
     if (!mImports.Get(key, &mod) && !mInProgressImports.Get(key, &mod)) {
         newEntry = new ModuleEntry;
         if (!newEntry || !mInProgressImports.Put(key, newEntry))
             return NS_ERROR_OUT_OF_MEMORY;
 
-        jsval exception = JSVAL_VOID;
+        JS::Anchor<jsval> exception(JSVAL_VOID);
         rv = GlobalForLocation(sourceLocalFile, resURI, &newEntry->global,
-                               &newEntry->location, &exception);
+                               &newEntry->location, &exception.get());
 
         mInProgressImports.Remove(key);
 
         if (NS_FAILED(rv)) {
             *_retval = nsnull;
 
-            if (!JSVAL_IS_VOID(exception)) {
+            if (!JSVAL_IS_VOID(exception.get())) {
                 // An exception was thrown during compilation. Propagate it
                 // out to our caller so they can report it.
-                JS_SetPendingException(callercx, exception);
+                if (!JS_WrapValue(callercx, &exception.get()))
+                    return NS_ERROR_OUT_OF_MEMORY;
+                JS_SetPendingException(callercx, exception.get());
                 return NS_OK;
             }
 
             // Something failed, but we don't know what it is, guess.
             return NS_ERROR_FILE_NOT_FOUND;
         }
 
         mod = newEntry;