From ef1541880778c16a17f678ddb4321268e30b9902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Tue, 19 Nov 2024 14:49:42 +0100 Subject: [PATCH] Fix null deref in js_iterator_helper_next Fixes: https://github.com/quickjs-ng/quickjs/issues/705 --- quickjs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/quickjs.c b/quickjs.c index c5802d7..0ed8b05 100644 --- a/quickjs.c +++ b/quickjs.c @@ -40615,7 +40615,7 @@ static JSValue js_iterator_helper_next(JSContext *ctx, JSValue this_val, it = JS_GetOpaque2(ctx, this_val, JS_CLASS_ITERATOR_HELPER); if (!it) - goto fail; + return JS_EXCEPTION; if (it->executing) return JS_ThrowTypeError(ctx, "cannot invoke a running iterator"); if (it->done) { @@ -40847,10 +40847,8 @@ done: it->executing = 0; return ret; fail: - if (it) { - /* close the iterator object, preserving pending exception */ - JS_IteratorClose(ctx, it->obj, TRUE); - } + /* close the iterator object, preserving pending exception */ + JS_IteratorClose(ctx, it->obj, TRUE); ret = JS_EXCEPTION; goto done; }