diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index e8810a520e6c..b3581ec7706e 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -163,7 +163,8 @@ Bindings::switchToScriptStorage(Binding *newBindingArray) JS_ASSERT(bindingArrayUsingTemporaryStorage()); JS_ASSERT(!(uintptr_t(newBindingArray) & TEMPORARY_STORAGE_BIT)); - PodCopy(newBindingArray, bindingArray(), count()); + if (count() > 0) + PodCopy(newBindingArray, bindingArray(), count()); bindingArrayAndFlag_ = uintptr_t(newBindingArray); return reinterpret_cast(newBindingArray + count()); } @@ -1947,9 +1948,13 @@ JSScript::partiallyInit(ExclusiveContext *cx, HandleScript script, uint32_t ncon { size_t size = ScriptDataSize(script->bindings.count(), nconsts, nobjects, nregexps, ntrynotes, nblockscopes); - script->data = AllocScriptData(cx, size); - if (!script->data) - return false; + if (size > 0) { + script->data = AllocScriptData(cx, size); + if (!script->data) + return false; + } else { + script->data = nullptr; + } script->dataSize_ = size; JS_ASSERT(nTypeSets <= UINT16_MAX);