Bug 919209 - Throw re-reports exception onto context. r=bholley
authorDeian Stefan <deian@cs.stanford.edu>
Wed, 09 Oct 2013 14:43:15 -0700
changeset 165518 7f9c148d281cae3cf54a674bf2e592ca30e3f988
parent 165456 45881cb21593f15e87fb06c300a844e43eb054b6
child 165519 b83bf0fa7adc34df718671afa2cd7ccfc4e857ce
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs919209
milestone27.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 919209 - Throw re-reports exception onto context. r=bholley
dom/bindings/Exceptions.cpp
--- a/dom/bindings/Exceptions.cpp
+++ b/dom/bindings/Exceptions.cpp
@@ -109,17 +109,26 @@ Throw(JSContext* aCx, nsresult aRv, cons
   }
 
   CycleCollectedJSRuntime* runtime = CycleCollectedJSRuntime::Get();
   nsCOMPtr<nsIException> existingException = runtime->GetPendingException();
   if (existingException) {
     nsresult nr;
     if (NS_SUCCEEDED(existingException->GetResult(&nr)) && 
         aRv == nr) {
-      // Just reuse the existing exception.
+      // Reuse the existing exception.
+
+      // Clear pending exception
+      runtime->SetPendingException(nullptr);
+
+      if (!ThrowExceptionObject(aCx, existingException)) {
+        // If we weren't able to throw an exception we're
+        // most likely out of memory
+        JS_ReportOutOfMemory(aCx);
+      }
       return false;
     }
   }
 
   nsRefPtr<Exception> finalException;
 
   // Do we use DOM exceptions for this error code?
   switch (NS_ERROR_GET_MODULE(aRv)) {