diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2023-12-13 19:01:10 +0100 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2023-12-13 19:01:10 +0100 |
commit | a42681a4a324dcfad1f3431b532a27e3a08189d0 (patch) | |
tree | 1ec9c6b7dcb8fe26aa9c5a28bac940832c41cf26 /quickjs.c | |
parent | a610598df6f0cb920ba877adbc9a29f83954df52 (diff) | |
download | quickjs-a42681a4a324dcfad1f3431b532a27e3a08189d0.tar.gz quickjs-a42681a4a324dcfad1f3431b532a27e3a08189d0.zip |
Fix AsyncGenerator.prototype.return error handling (bnoordhuis)
Diffstat (limited to 'quickjs.c')
-rw-r--r-- | quickjs.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -19175,10 +19175,19 @@ static int js_async_generator_completed_return(JSContext *ctx, JSValue promise, resolving_funcs[2], resolving_funcs1[2]; int res; - promise = js_promise_resolve(ctx, ctx->promise_ctor, - 1, (JSValueConst *)&value, 0); - if (JS_IsException(promise)) - return -1; + // Can fail looking up JS_ATOM_constructor when is_reject==0. + promise = js_promise_resolve(ctx, ctx->promise_ctor, 1, &value, + /*is_reject*/0); + // A poisoned .constructor property is observable and the resulting + // exception should be delivered to the catch handler. + if (JS_IsException(promise)) { + JSValue err = JS_GetException(ctx); + promise = js_promise_resolve(ctx, ctx->promise_ctor, 1, &err, + /*is_reject*/1); + JS_FreeValue(ctx, err); + if (JS_IsException(promise)) + return -1; + } if (js_async_generator_resolve_function_create(ctx, JS_MKPTR(JS_TAG_OBJECT, s->generator), resolving_funcs1, |