summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2025-04-21 16:12:56 +0200
committerFabrice Bellard <fabrice@bellard.org>2025-04-21 16:12:56 +0200
commit334aa18013f8b3889b8bdddfea68e35830dbcadc (patch)
tree3c6a3476df3563fd8405efefa688087a670b17ca
parentdbbca3dbf3856938120071225a5e4c906d3177e8 (diff)
downloadquickjs-334aa18013f8b3889b8bdddfea68e35830dbcadc.tar.gz
quickjs-334aa18013f8b3889b8bdddfea68e35830dbcadc.zip
fixed iterator close in Map/Set constructor
-rw-r--r--quickjs.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/quickjs.c b/quickjs.c
index ac00898..85dc0d0 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -47148,7 +47148,7 @@ static JSValue js_map_constructor(JSContext *ctx, JSValueConst new_target,
ret = JS_Call(ctx, adder, obj, 1, (JSValueConst *)&item);
if (JS_IsException(ret)) {
JS_FreeValue(ctx, item);
- goto fail;
+ goto fail_close;
}
} else {
JSValue key, value;
@@ -47173,7 +47173,7 @@ static JSValue js_map_constructor(JSContext *ctx, JSValueConst new_target,
JS_FreeValue(ctx, item);
JS_FreeValue(ctx, key);
JS_FreeValue(ctx, value);
- goto fail;
+ goto fail_close;
}
JS_FreeValue(ctx, key);
JS_FreeValue(ctx, value);
@@ -47186,11 +47186,10 @@ static JSValue js_map_constructor(JSContext *ctx, JSValueConst new_target,
JS_FreeValue(ctx, adder);
}
return obj;
+ fail_close:
+ /* close the iterator object, preserving pending exception */
+ JS_IteratorClose(ctx, iter, TRUE);
fail:
- if (JS_IsObject(iter)) {
- /* close the iterator object, preserving pending exception */
- JS_IteratorClose(ctx, iter, TRUE);
- }
JS_FreeValue(ctx, next_method);
JS_FreeValue(ctx, iter);
JS_FreeValue(ctx, adder);