diff options
author | Kasper Isager Dalsgarð <kasperisager@hey.com> | 2024-07-17 13:58:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-17 13:58:08 +0200 |
commit | 5417ab0159fc48c217ff91344a833d3286b8895d (patch) | |
tree | dff50518c2eb9dafb600005e7d2a1de227b65ab3 /quickjs.c | |
parent | b3715f7cb1f7e7e99fa5e768e3af3f6bb22ae50f (diff) | |
download | quickjs-5417ab0159fc48c217ff91344a833d3286b8895d.tar.gz quickjs-5417ab0159fc48c217ff91344a833d3286b8895d.zip |
Fix `JS_HasException()` when `null` is thrown (#313)
Use `JS_UNINITIALIZED` instead of `JS_NULL` when no exception is pending, so `null` can be thrown and distinguished from no exception pending.
Diffstat (limited to 'quickjs.c')
-rw-r--r-- | quickjs.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1681,7 +1681,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: @@ -6398,13 +6398,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) @@ -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; @@ -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; } |