Skip to content

Commit

Permalink
Fix null deref in js_iterator_helper_next
Browse files Browse the repository at this point in the history
Fixes: #705
  • Loading branch information
saghul committed Nov 19, 2024
1 parent 0b9b6c1 commit db6693c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -40847,10 +40847,8 @@ static JSValue js_iterator_helper_next(JSContext *ctx, JSValue this_val,
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;
}
Expand Down

0 comments on commit db6693c

Please sign in to comment.