]> git.kaiwu.me - quickjs.git/commitdiff
Fix GC leak in `js_proxy_get()` (#302)
authorDmitry Volyntsev <xeioexception@gmail.com>
Sun, 14 Jul 2024 22:08:40 +0000 (15:08 -0700)
committerGitHub <noreply@github.com>
Sun, 14 Jul 2024 22:08:40 +0000 (00:08 +0200)
Fixes #277

quickjs.c

index f000ff74ee3251e53df4887122591031653542ea..268bc8422783226073f959128ef1ec4c2acf0546 100644 (file)
--- a/quickjs.c
+++ b/quickjs.c
@@ -46151,8 +46151,10 @@ static JSValue js_proxy_get(JSContext *ctx, JSValueConst obj, JSAtom atom,
     if (JS_IsException(ret))
         return JS_EXCEPTION;
     res = JS_GetOwnPropertyInternal(ctx, &desc, JS_VALUE_GET_OBJ(s->target), atom);
-    if (res < 0)
+    if (res < 0) {
+        JS_FreeValue(ctx, ret);
         return JS_EXCEPTION;
+    }
     if (res) {
         if ((desc.flags & (JS_PROP_GETSET | JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE)) == 0) {
             if (!js_same_value(ctx, desc.value, ret)) {