diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index e96ffa5ce68..b8a869236bf 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -757,6 +757,15 @@ JSPCCounters::init(JSContext *cx, size_t numBytecodes) return true; } +void +JSPCCounters::destroy(JSContext *cx) +{ + if (counts) { + cx->free_(counts); + counts = NULL; + } +} + static void script_finalize(JSContext *cx, JSObject *obj) { @@ -1499,6 +1508,8 @@ DestroyScript(JSContext *cx, JSScript *script) #endif JS_REMOVE_LINK(&script->links); + script->pcCounters.destroy(cx); + cx->free_(script); } diff --git a/js/src/jsscript.h b/js/src/jsscript.h index 0aa486fbb91..3f0cecc013b 100644 --- a/js/src/jsscript.h +++ b/js/src/jsscript.h @@ -404,10 +404,11 @@ class JSPCCounters { } ~JSPCCounters() { - js::UnwantedForeground::free_(counts); + JS_ASSERT(!counts); } bool init(JSContext *cx, size_t numBytecodes); + void destroy(JSContext *cx); // Boolean conversion, for 'if (counters) ...' operator void*() const {