mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1166041 - Fix memory leaked by nursery when we hit OOM r=terrence
This commit is contained in:
parent
b38fcaf496
commit
885ad20f3a
@ -246,9 +246,9 @@ js::Nursery::allocateBuffer(Zone* zone, uint32_t nbytes)
|
||||
}
|
||||
|
||||
void* buffer = zone->pod_malloc<uint8_t>(nbytes);
|
||||
if (buffer) {
|
||||
/* If this put fails, we will only leak the slots. */
|
||||
(void)mallocedBuffers.put(buffer);
|
||||
if (buffer && !mallocedBuffers.putNew(buffer)) {
|
||||
js_free(buffer);
|
||||
return nullptr;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
@ -273,11 +273,8 @@ js::Nursery::reallocateBuffer(JSObject* obj, void* oldBuffer,
|
||||
|
||||
if (!isInside(oldBuffer)) {
|
||||
void* newBuffer = obj->zone()->pod_realloc<uint8_t>((uint8_t*)oldBuffer, oldBytes, newBytes);
|
||||
if (newBuffer && oldBytes != newBytes) {
|
||||
removeMallocedBuffer(oldBuffer);
|
||||
/* If this put fails, we will only leak the slots. */
|
||||
(void)mallocedBuffers.put(newBuffer);
|
||||
}
|
||||
if (newBuffer && oldBuffer != newBuffer)
|
||||
MOZ_ALWAYS_TRUE(mallocedBuffers.rekeyAs(oldBuffer, newBuffer, newBuffer));
|
||||
return newBuffer;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user