From 61dae5d4204a33b7642cc06b1d8d7ea77e21fd21 Mon Sep 17 00:00:00 2001 From: Penner Date: Mon, 25 Nov 2024 12:13:43 +0800 Subject: [PATCH] fix crash when add property maybe failed on build arguments --- quickjs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/quickjs.c b/quickjs.c index f25f86fc..b8090de1 100644 --- a/quickjs.c +++ b/quickjs.c @@ -13571,6 +13571,10 @@ static JSValue js_build_arguments(JSContext *ctx, int argc, JSValue *argv) /* add the length field (cannot fail) */ pr = add_property(ctx, p, JS_ATOM_length, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); + if (!pr) { + JS_FreeValue(ctx, val); + return JS_EXCEPTION; + } pr->u.value = js_int32(argc); /* initialize the fast array part */ @@ -13620,6 +13624,8 @@ static JSValue js_build_mapped_arguments(JSContext *ctx, int argc, /* add the length field (cannot fail) */ pr = add_property(ctx, p, JS_ATOM_length, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); + if (!pr) + goto fail; pr->u.value = js_int32(argc); for(i = 0; i < arg_count; i++) {