]> git.kaiwu.me - quickjs.git/commitdiff
fixed memory leak in Atomics.store (#537)
authorFabrice Bellard <fabrice@bellard.org>
Sat, 26 Sep 2026 13:12:07 +0000 (15:12 +0200)
committerFabrice Bellard <fabrice@bellard.org>
Sat, 26 Sep 2026 13:12:07 +0000 (15:12 +0200)
quickjs.c

index adfed759a0ceb0e863e9ac3381c03eaa3fdd6633..48eeb2bea636418dd0b7c7a82ad935279d82167e 100644 (file)
--- a/quickjs.c
+++ b/quickjs.c
@@ -60804,10 +60804,14 @@ static JSValue js_atomics_store(JSContext *ctx,
         }
         v = v32;
     }
-    if (typed_array_is_oob(p))
+    if (typed_array_is_oob(p)) {
+        JS_FreeValue(ctx, ret);
         return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
-    if (idx >= p->u.array.count)
+    }
+    if (idx >= p->u.array.count) {
+        JS_FreeValue(ctx, ret);
         return JS_ThrowRangeError(ctx, "out-of-bound access");
+    }
 
     ptr = p->u.array.u.uint8_ptr + ((uintptr_t)idx << size_log2);