From: Fabrice Bellard Date: Sat, 21 Nov 2026 13:13:46 +0000 (+0100) Subject: don't take value of dropped iterator items X-Git-Url: https://git.kaiwu.me/http/ngx_http_access_module.html?a=commitdiff_plain;h=2f97a49dbc3816b9e8a931c91cdb30a56bb64e44;p=quickjs.git don't take value of dropped iterator items --- diff --git a/quickjs.c b/quickjs.c index 55ffcbc..bb092d0 100644 --- a/quickjs.c +++ b/quickjs.c @@ -47194,9 +47194,18 @@ static JSValue js_iterator_helper_next(JSContext *ctx, JSValueConst this_val, JSValue item; while (it->count > 0) { it->count--; - item = JS_IteratorNext(ctx, it->obj, it->next, pdone); + item = JS_IteratorNext2(ctx, it->obj, it->next, 0, NULL, pdone); if (JS_IsException(item)) goto fail_no_close; + if (*pdone == 2) { + JSValue done_val; + done_val = JS_GetProperty(ctx, item, JS_ATOM_done); + if (JS_IsException(done_val)) { + JS_FreeValue(ctx, item); + goto fail_no_close; + } + *pdone = JS_ToBoolFree(ctx, done_val); + } JS_FreeValue(ctx, item); if (*pdone) { ret = JS_UNDEFINED;