From d528552bcaff2d44bd911c1c3746adccc2e478d0 Mon Sep 17 00:00:00 2001 From: Andreas Gal Date: Sat, 31 May 2008 18:12:39 -0700 Subject: [PATCH] Assign fresh loop table slots for all JSOP_HEADER opcodes in a script as it is thawed since the slots we stored there are likely stale by now. --- js/src/jsscript.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index db32835d5b2..e83d4ca45a8 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -535,6 +535,19 @@ js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *hasMagic) if (!ok) goto error; + jsbytecode *pc = code; + jsbytecode *end = pc + length; + while (pc < end) { + JSOp op = (JSOp)*pc; + int len = js_CodeSpec[op].length; + if (!len) + goto error; + /* Assign a new loop table slot for every JSOP_HEADER opcode. */ + if (op == JSOP_HEADER) + SET_UINT24(pc + 1, js_AllocateLoopTableSlot(cx->runtime)); + pc += len; + } + if (!JS_XDRBytes(xdr, (char *)notes, nsrcnotes * sizeof(jssrcnote)) || !JS_XDRCStringOrNull(xdr, (char **)&script->filename) || !JS_XDRUint32(xdr, &lineno) ||