Bug 963528 - Don't allocate zero-sized script data. r=luke.

--HG--
extra : rebase_source : 16beebadc53671e68b73d920ad96c366f48206d3
This commit is contained in:
Nicholas Nethercote 2014-01-27 18:31:34 -08:00
parent d02ad93210
commit 29804a9976

View File

@ -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<uint8_t *>(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);