mirror of
https://github.com/bellard/quickjs.git
synced 2026-06-07 06:32:08 +00:00
Check return values of fallible functions (#518)
Port of https://github.com/quickjs-ng/quickjs/pull/1409 (bnoordhuis). I modified it to prevent an atom leak in js_parse_statement_or_decl, otherwise it's the same.
This commit is contained in:
parent
8b045501f9
commit
ccfe0764ed
11
quickjs.c
11
quickjs.c
@ -28718,7 +28718,8 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name,
|
||||
int chunk_size = pos_expr - pos_next;
|
||||
int offset = bc->size - pos_next;
|
||||
int i;
|
||||
dbuf_claim(bc, chunk_size);
|
||||
if (dbuf_claim(bc, chunk_size))
|
||||
return -1;
|
||||
dbuf_put(bc, bc->buf + pos_next, chunk_size);
|
||||
memset(bc->buf + pos_next, OP_nop, chunk_size);
|
||||
/* `next` part ends with a goto */
|
||||
@ -29124,7 +29125,8 @@ static __exception int js_parse_statement_or_decl(JSParseState *s,
|
||||
int chunk_size = pos_body - pos_cont;
|
||||
int offset = bc->size - pos_cont;
|
||||
int i;
|
||||
dbuf_claim(bc, chunk_size);
|
||||
if (dbuf_claim(bc, chunk_size))
|
||||
goto fail;
|
||||
dbuf_put(bc, bc->buf + pos_cont, chunk_size);
|
||||
memset(bc->buf + pos_cont, OP_nop, chunk_size);
|
||||
/* increment part ends with a goto */
|
||||
@ -38052,11 +38054,14 @@ static int JS_WriteObjectRec(BCWriterState *s, JSValueConst obj)
|
||||
case JS_TAG_STRING_ROPE:
|
||||
{
|
||||
JSValue str;
|
||||
int ret;
|
||||
str = JS_ToString(s->ctx, obj);
|
||||
if (JS_IsException(str))
|
||||
goto fail;
|
||||
JS_WriteObjectRec(s, str);
|
||||
ret = JS_WriteObjectRec(s, str);
|
||||
JS_FreeValue(s->ctx, str);
|
||||
if (ret)
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case JS_TAG_FUNCTION_BYTECODE:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user