From 87bdf20c9d28e09927f5987bf71a61c4ffb714d2 Mon Sep 17 00:00:00 2001 From: "mrbkap%gmail.com" Date: Fri, 21 Oct 2005 00:26:56 +0000 Subject: [PATCH] bug 312278: Protect some objects from getting GC'd before we could root them. r=brendan git-svn-id: svn://10.0.0.236/trunk@182667 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/src/jsexn.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mozilla/js/src/jsexn.c b/mozilla/js/src/jsexn.c index 266a3a27a27..6cb393cd112 100644 --- a/mozilla/js/src/jsexn.c +++ b/mozilla/js/src/jsexn.c @@ -985,6 +985,11 @@ js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp) return JS_FALSE; cx->creatingException = JS_TRUE; + /* Protect the newly-created strings below from nesting GCs. */ + ok = js_EnterLocalRootScope(cx); + if (!ok) + goto out; + /* * Try to get an appropriate prototype by looking up the corresponding * exception constructor name in the scope chain of the current context's @@ -1047,6 +1052,7 @@ js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp) reportp->flags |= JSREPORT_EXCEPTION; out: + js_LeaveLocalRootScope(cx); cx->creatingException = JS_FALSE; return ok; }