mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-04 07:40:42 +00:00
Bug 1376585 - prevent memory leak in setCloneBuffer_impl. r=jandem
MozReview-Commit-ID: HX2Siss7un2 --HG-- extra : rebase_source : 8d11eea64bd23028c9242c399bcbf74363fd3229
This commit is contained in:
parent
3457de183e
commit
e6beae2ce2
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user