mirror of
https://github.com/bellard/quickjs.git
synced 2025-05-15 02:36:17 +08:00
workaround for overflow test in JS_GetOwnPropertyNamesInternal() (#111)
This commit is contained in:
parent
beeb2725cd
commit
c1bf4e99db
16
quickjs.c
16
quickjs.c
@ -7936,7 +7936,21 @@ static int __exception JS_GetOwnPropertyNamesInternal(JSContext *ctx,
|
|||||||
|
|
||||||
/* fill them */
|
/* fill them */
|
||||||
|
|
||||||
atom_count = num_keys_count + str_keys_count + sym_keys_count + exotic_keys_count;
|
atom_count = num_keys_count + str_keys_count;
|
||||||
|
if (atom_count < str_keys_count)
|
||||||
|
goto add_overflow;
|
||||||
|
atom_count += sym_keys_count;
|
||||||
|
if (atom_count < sym_keys_count)
|
||||||
|
goto add_overflow;
|
||||||
|
atom_count += exotic_keys_count;
|
||||||
|
if (atom_count < exotic_keys_count || atom_count > INT32_MAX) {
|
||||||
|
add_overflow:
|
||||||
|
JS_ThrowOutOfMemory(ctx);
|
||||||
|
js_free_prop_enum(ctx, tab_exotic, exotic_count);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* XXX: need generic way to test for js_malloc(ctx, a * b) overflow */
|
||||||
|
|
||||||
/* avoid allocating 0 bytes */
|
/* avoid allocating 0 bytes */
|
||||||
tab_atom = js_malloc(ctx, sizeof(tab_atom[0]) * max_int(atom_count, 1));
|
tab_atom = js_malloc(ctx, sizeof(tab_atom[0]) * max_int(atom_count, 1));
|
||||||
if (!tab_atom) {
|
if (!tab_atom) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user