Bug 1376585 - prevent memory leak in setCloneBuffer_impl. r=jandem

MozReview-Commit-ID: HX2Siss7un2

--HG--
extra : rebase_source : 8d11eea64bd23028c9242c399bcbf74363fd3229
This commit is contained in:
Andi-Bogdan Postelnicu 2017-06-27 14:48:57 -07:00
parent 3457de183e
commit e6beae2ce2

View File

@ -2378,8 +2378,10 @@ class CloneBufferObject : public NativeObject {
size_t nbytes = JS_GetStringLength(args[0].toString());
MOZ_ASSERT(nbytes % sizeof(uint64_t) == 0);
auto buf = js::MakeUnique<JSStructuredCloneData>(0, 0, nbytes);
if (!buf->Init(nbytes, nbytes))
if (!buf->Init(nbytes, nbytes)) {
JS_free(cx, str);
return false;
}
js_memcpy(buf->Start(), str, nbytes);
JS_free(cx, str);
obj->setData(buf.release());