@@ -1549,6 +1549,12 @@ static JSValue js_number(double d)
15491549 return js_float64(d);
15501550}
15511551
1552+ static JSValue __JS_NewShortBigInt(JSContext *ctx, int32_t d)
1553+ {
1554+ (void)&ctx;
1555+ return JS_MKVAL(JS_TAG_SHORT_BIG_INT, d);
1556+ }
1557+
15521558JSValue JS_NewNumber(JSContext *ctx, double d)
15531559{
15541560 return js_number(d);
@@ -4549,6 +4555,8 @@ JSValue JS_NewStringUTF16(JSContext *ctx, const uint16_t *buf, size_t len)
45494555
45504556 if (unlikely(!len))
45514557 return js_empty_string(ctx->rt);
4558+ if (unlikely(len > JS_STRING_LEN_MAX))
4559+ return JS_ThrowRangeError(ctx, "invalid string length");
45524560
45534561 str = js_alloc_string(ctx, len, 1);
45544562 if (unlikely(!str))
@@ -7899,7 +7907,7 @@ static void build_backtrace(JSContext *ctx, JSValueConst error_val,
78997907 int line_num, int col_num, int backtrace_flags)
79007908{
79017909 JSStackFrame *sf, *sf_start;
7902- JSValue stack, prepare, saved_exception;
7910+ JSValue stack, prepare, saved_exception, error_obj ;
79037911 DynBuf dbuf;
79047912 const char *func_name_str;
79057913 const char *str1;
@@ -7916,6 +7924,7 @@ static void build_backtrace(JSContext *ctx, JSValueConst error_val,
79167924 if (rt->in_build_stack_trace)
79177925 return;
79187926 rt->in_build_stack_trace = true;
7927+ error_obj = js_dup(error_val);
79197928
79207929 // Save exception because conversion to double may fail.
79217930 saved_exception = JS_GetException(ctx);
@@ -8061,7 +8070,7 @@ static void build_backtrace(JSContext *ctx, JSValueConst error_val,
80618070 JS_FreeValue(ctx, csd[k].func_name);
80628071 }
80638072 JSValueConst args[] = {
8064- error_val ,
8073+ error_obj ,
80658074 stack,
80668075 };
80678076 JSValue stack2 = JS_Call(ctx, prepare, ctx->error_ctor, countof(args), args);
@@ -8082,13 +8091,14 @@ static void build_backtrace(JSContext *ctx, JSValueConst error_val,
80828091
80838092 if (JS_IsUndefined(ctx->error_back_trace))
80848093 ctx->error_back_trace = js_dup(stack);
8085- if (has_filter_func || can_add_backtrace(error_val )) {
8086- JS_DefinePropertyValue(ctx, error_val , JS_ATOM_stack, stack,
8094+ if (has_filter_func || can_add_backtrace(error_obj )) {
8095+ JS_DefinePropertyValue(ctx, error_obj , JS_ATOM_stack, stack,
80878096 JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
80888097 } else {
80898098 JS_FreeValue(ctx, stack);
80908099 }
80918100
8101+ JS_FreeValue(ctx, error_obj);
80928102 rt->in_build_stack_trace = false;
80938103}
80948104
@@ -40444,7 +40454,7 @@ JSValue JS_ToObject(JSContext *ctx, JSValueConst val)
4044440454 if (!JS_IsException(obj)) {
4044540455 JS_DefinePropertyValue(ctx, obj, JS_ATOM_length,
4044640456 JS_NewInt32(ctx, JS_VALUE_GET_STRING(str)->len), 0);
40447- JS_SetObjectData(ctx, obj, JS_DupValue(ctx, str));
40457+ JS_SetObjectData(ctx, obj, js_dup( str));
4044840458 }
4044940459 JS_FreeValue(ctx, str);
4045040460 return obj;
0 commit comments