fix mach vm suite errors

This commit is contained in:
2026-02-09 18:12:44 -06:00
parent d5209e1d59
commit 7f691fd52b
4 changed files with 50 additions and 28 deletions

View File

@@ -5974,7 +5974,7 @@ static int js_json_to_str (JSContext *ctx, JSONStringifyContext *jsc, JSValue ho
int64_t i, len;
int ret;
BOOL has_content;
JSGCRef val_ref, indent_ref, indent1_ref, sep_ref, sep1_ref, tab_ref, prop_ref;
JSGCRef val_ref, indent_ref, indent1_ref, sep_ref, sep1_ref, tab_ref, prop_ref, v_ref;
/* Root all values that can be heap pointers and survive across GC points */
JS_PushGCRef (ctx, &val_ref);
@@ -5984,6 +5984,7 @@ static int js_json_to_str (JSContext *ctx, JSONStringifyContext *jsc, JSValue ho
JS_PushGCRef (ctx, &sep1_ref);
JS_PushGCRef (ctx, &tab_ref);
JS_PushGCRef (ctx, &prop_ref);
JS_PushGCRef (ctx, &v_ref);
val_ref.val = val;
indent_ref.val = indent;
@@ -5992,6 +5993,7 @@ static int js_json_to_str (JSContext *ctx, JSONStringifyContext *jsc, JSValue ho
sep1_ref.val = JS_NULL;
tab_ref.val = JS_NULL;
prop_ref.val = JS_NULL;
v_ref.val = JS_NULL;
if (js_check_stack_overflow (ctx, 0)) {
JS_ThrowStackOverflow (ctx);
@@ -6038,10 +6040,11 @@ static int js_json_to_str (JSContext *ctx, JSONStringifyContext *jsc, JSValue ho
JSC_B_CONCAT (jsc, sep_ref.val);
v = JS_GetPropertyInt64 (ctx, val_ref.val, i);
if (JS_IsException (v)) goto exception;
v_ref.val = v; /* root v — JS_ToString below can trigger GC */
/* XXX: could do this string conversion only when needed */
prop_ref.val = JS_ToString (ctx, JS_NewInt64 (ctx, i));
if (JS_IsException (prop_ref.val)) goto exception;
v = js_json_check (ctx, jsc, val_ref.val, v, prop_ref.val);
v = js_json_check (ctx, jsc, val_ref.val, v_ref.val, prop_ref.val);
prop_ref.val = JS_NULL;
if (JS_IsException (v)) goto exception;
if (JS_IsNull (v)) v = JS_NULL;
@@ -6069,6 +6072,7 @@ static int js_json_to_str (JSContext *ctx, JSONStringifyContext *jsc, JSValue ho
v = js_json_check (ctx, jsc, val_ref.val, v, prop_ref.val);
if (JS_IsException (v)) goto exception;
if (!JS_IsNull (v)) {
v_ref.val = v; /* root v — allocations below can trigger GC */
if (has_content) {
JSC_B_PUTC (jsc, ',');
}
@@ -6080,7 +6084,7 @@ static int js_json_to_str (JSContext *ctx, JSONStringifyContext *jsc, JSValue ho
JSC_B_CONCAT (jsc, prop_ref.val);
JSC_B_PUTC (jsc, ':');
JSC_B_CONCAT (jsc, sep1_ref.val);
if (js_json_to_str (ctx, jsc, val_ref.val, v, indent1_ref.val)) goto exception;
if (js_json_to_str (ctx, jsc, val_ref.val, v_ref.val, indent1_ref.val)) goto exception;
has_content = TRUE;
}
}
@@ -6116,6 +6120,7 @@ static int js_json_to_str (JSContext *ctx, JSONStringifyContext *jsc, JSValue ho
}
done:
JS_PopGCRef (ctx, &v_ref);
JS_PopGCRef (ctx, &prop_ref);
JS_PopGCRef (ctx, &tab_ref);
JS_PopGCRef (ctx, &sep1_ref);
@@ -6126,6 +6131,7 @@ done:
return 0;
exception_ret:
JS_PopGCRef (ctx, &v_ref);
JS_PopGCRef (ctx, &prop_ref);
JS_PopGCRef (ctx, &tab_ref);
JS_PopGCRef (ctx, &sep1_ref);