diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2025-04-21 16:12:56 +0200 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2025-04-21 16:12:56 +0200 |
commit | 334aa18013f8b3889b8bdddfea68e35830dbcadc (patch) | |
tree | 3c6a3476df3563fd8405efefa688087a670b17ca | |
parent | dbbca3dbf3856938120071225a5e4c906d3177e8 (diff) | |
download | quickjs-334aa18013f8b3889b8bdddfea68e35830dbcadc.tar.gz quickjs-334aa18013f8b3889b8bdddfea68e35830dbcadc.zip |
fixed iterator close in Map/Set constructor
-rw-r--r-- | quickjs.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -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); |