]> git.kaiwu.me - quickjs.git/commitdiff
added missing stack overflow check in JSON.stringify()
authorFabrice Bellard <fabrice@bellard.org>
Thu, 13 Mar 2025 16:27:38 +0000 (17:27 +0100)
committerFabrice Bellard <fabrice@bellard.org>
Thu, 13 Mar 2025 16:27:38 +0000 (17:27 +0100)
quickjs.c

index 8871a71cd39ec7929aac85bee5a8a4a4a86f96e2..8ba1188b2bb8234dbc088f0f4050aa98b8d07fef 100644 (file)
--- a/quickjs.c
+++ b/quickjs.c
@@ -45412,6 +45412,11 @@ static int js_json_to_str(JSContext *ctx, JSONStringifyContext *jsc,
     tab = JS_UNDEFINED;
     prop = JS_UNDEFINED;
 
+    if (js_check_stack_overflow(ctx->rt, 0)) {
+        JS_ThrowStackOverflow(ctx);
+        goto exception;
+    }
+
     if (JS_IsObject(val)) {
         p = JS_VALUE_GET_OBJ(val);
         cl = p->class_id;