Bug 473437 - DumpJSStack() can set a pending exception in cx. r+sr=jst
authorBlake Kaplan <mrbkap@gmail.com>
Thu, 15 Jan 2009 16:34:54 -0800
changeset 23768 94b8ea0a2a1001e4e5feac72cf925f29f6c14a27
parent 23767 0c62506aefd654c894046e0619743d3305cf6592
child 23769 d1c518aec998b6b2cfdad305c80996ddbcee9b60
push id4717
push usermrbkap@mozilla.com
push dateFri, 16 Jan 2009 00:35:57 +0000
treeherdermozilla-central@62ff51a9286c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs473437
milestone1.9.2a1pre
Bug 473437 - DumpJSStack() can set a pending exception in cx. r+sr=jst
js/src/xpconnect/src/xpcdebug.cpp
--- a/js/src/xpconnect/src/xpcdebug.cpp
+++ b/js/src/xpconnect/src/xpcdebug.cpp
@@ -286,25 +286,32 @@ static char* FormatJSStackDump(JSContext
 
     return buf;
 }
 
 JSBool
 xpc_DumpJSStack(JSContext* cx, JSBool showArgs, JSBool showLocals, JSBool showThisProps)
 {
     char* buf;
+    JSExceptionState *state = JS_SaveExceptionState(cx);
+    if(!state)
+        puts("Call to a debug function modifying state!");
+
+    JS_ClearPendingException(cx);
 
     buf = FormatJSStackDump(cx, nsnull, showArgs, showLocals, showThisProps);
     if(buf)
     {
         fputs(buf, stdout);
         JS_smprintf_free(buf);
     }
     else
         puts("Failed to format JavaScript stack for dump");
+
+    JS_RestoreExceptionState(cx, state);
     return JS_TRUE;
 }
 
 /***************************************************************************/
 
 static void
 xpcDumpEvalErrorReporter(JSContext *cx, const char *message,
                          JSErrorReport *report)