Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JS_HasException() when null is thrown #313

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@ JSRuntime *JS_NewRuntime2(const JSMallocFunctions *mf, void *opaque)
rt->stack_size = JS_DEFAULT_STACK_SIZE;
JS_UpdateStackTop(rt);

rt->current_exception = JS_NULL;
rt->current_exception = JS_UNINITIALIZED;

return rt;
fail:
Expand Down Expand Up @@ -6397,13 +6397,13 @@ JSValue JS_GetException(JSContext *ctx)
JSValue val;
JSRuntime *rt = ctx->rt;
val = rt->current_exception;
rt->current_exception = JS_NULL;
rt->current_exception = JS_UNINITIALIZED;
return val;
}

JS_BOOL JS_HasException(JSContext *ctx)
{
return !JS_IsNull(ctx->rt->current_exception);
return !JS_IsUninitialized(ctx->rt->current_exception);
}

static void dbuf_put_leb128(DynBuf *s, uint32_t v)
Expand Down Expand Up @@ -15321,7 +15321,7 @@ static int JS_IteratorClose(JSContext *ctx, JSValueConst enum_obj,

if (is_exception_pending) {
ex_obj = ctx->rt->current_exception;
ctx->rt->current_exception = JS_NULL;
ctx->rt->current_exception = JS_UNINITIALIZED;
res = -1;
} else {
ex_obj = JS_UNDEFINED;
Expand Down Expand Up @@ -18674,7 +18674,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
JS_IteratorClose(ctx, sp[-1], TRUE);
} else {
*sp++ = rt->current_exception;
rt->current_exception = JS_NULL;
rt->current_exception = JS_UNINITIALIZED;
pc = b->byte_code_buf + pos;
goto restart;
}
Expand Down