From 10edcd5f4aed6ea3e6d1ff129d0f82f44b820ca1 Mon Sep 17 00:00:00 2001 From: "brendan%mozilla.org" Date: Fri, 11 Apr 2008 14:50:16 +0000 Subject: [PATCH] Fix 427191 (r=igor, a=beltzner). git-svn-id: svn://10.0.0.236/trunk@250064 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/src/jsfun.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/mozilla/js/src/jsfun.c b/mozilla/js/src/jsfun.c index 79490ad23e2..44b88e04fde 100644 --- a/mozilla/js/src/jsfun.c +++ b/mozilla/js/src/jsfun.c @@ -2183,17 +2183,24 @@ js_ReportIsNotFunction(JSContext *cx, jsval *vp, uintN flags) JSStackFrame *fp; uintN error; const char *name, *source; + JSTempValueRooter tvr; for (fp = cx->fp; fp && !fp->regs; fp = fp->down) continue; - name = NULL; - source = NULL; + name = source = NULL; + JS_PUSH_TEMP_ROOT_STRING(cx, NULL, &tvr); if (flags & JSV2F_ITERATOR) { error = JSMSG_BAD_ITERATOR; name = js_iterator_str; - source = js_ValueToPrintableSource(cx, *vp); + tvr.u.string = js_ValueToSource(cx, *vp); + if (!tvr.u.string) + goto out; + tvr.u.string = js_QuoteString(cx, tvr.u.string, 0); + if (!tvr.u.string) + goto out; + source = js_GetStringBytes(cx, tvr.u.string); if (!source) - return; + goto out; } else if (flags & JSV2F_CONSTRUCT) { error = JSMSG_NOT_CONSTRUCTOR; } else { @@ -2209,6 +2216,9 @@ js_ReportIsNotFunction(JSContext *cx, jsval *vp, uintN flags) : JSDVG_IGNORE_STACK, *vp, NULL, name, source); + + out: + JS_POP_TEMP_ROOT(cx, &tvr); } /*