mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 617505 - Don't OOM so easily growing dense arrays, r=gal
This commit is contained in:
parent
30c5928c9d
commit
6ec4576609
@ -1656,6 +1656,13 @@ struct JSRuntime {
|
||||
return JS_LIKELY(!!p) ? p : onOutOfMemory(reinterpret_cast<void *>(1), bytes, cx);
|
||||
}
|
||||
|
||||
void* realloc(void* p, size_t oldBytes, size_t newBytes, JSContext *cx = NULL) {
|
||||
JS_ASSERT(oldBytes < newBytes);
|
||||
updateMallocCounter(newBytes - oldBytes);
|
||||
void *p2 = ::js_realloc(p, newBytes);
|
||||
return JS_LIKELY(!!p2) ? p2 : onOutOfMemory(p, newBytes, cx);
|
||||
}
|
||||
|
||||
void* realloc(void* p, size_t bytes, JSContext *cx = NULL) {
|
||||
/*
|
||||
* For compatibility we do not account for realloc that increases
|
||||
@ -2295,6 +2302,10 @@ struct JSContext
|
||||
return runtime->realloc(p, bytes, this);
|
||||
}
|
||||
|
||||
inline void* realloc(void* p, size_t oldBytes, size_t newBytes) {
|
||||
return runtime->realloc(p, oldBytes, newBytes, this);
|
||||
}
|
||||
|
||||
inline void free(void* p) {
|
||||
#ifdef JS_THREADSAFE
|
||||
if (gcBackgroundFree) {
|
||||
|
@ -3939,7 +3939,7 @@ JSObject::growSlots(JSContext *cx, size_t newcap)
|
||||
if (!hasSlotsArray())
|
||||
return allocSlots(cx, actualCapacity);
|
||||
|
||||
Value *tmpslots = (Value*) cx->realloc(slots, actualCapacity * sizeof(Value));
|
||||
Value *tmpslots = (Value*) cx->realloc(slots, oldcap * sizeof(Value), actualCapacity * sizeof(Value));
|
||||
if (!tmpslots)
|
||||
return false; /* Leave dslots as its old size. */
|
||||
slots = tmpslots;
|
||||
|
Loading…
Reference in New Issue
Block a user