Bug 777083 - Don't leak when ownSource is true. r=luke

This commit is contained in:
Benjamin Peterson 2012-07-24 19:01:38 -07:00
parent 1ad7b84973
commit 3abd48772d

View File

@ -1183,12 +1183,14 @@ ScriptSource::createFromSource(JSContext *cx, const jschar *src, uint32_t length
ScriptSource *ss = static_cast<ScriptSource *>(cx->malloc_(sizeof(*ss)));
if (!ss)
return NULL;
if (!ownSource) {
const size_t memlen = length * sizeof(jschar);
ss->data.compressed = static_cast<unsigned char *>(cx->malloc_(memlen));
if (!ss->data.compressed) {
cx->free_(ss);
return NULL;
}
}
ss->next = NULL;
ss->length_ = length;
ss->compressedLength = 0;