]> git.kaiwu.me - quickjs.git/commitdiff
removed use after free in js_create_module_bytecode_function() (#467)
authorFabrice Bellard <fabrice@bellard.org>
Thu, 11 Dec 2025 18:18:56 +0000 (19:18 +0100)
committerFabrice Bellard <fabrice@bellard.org>
Thu, 11 Dec 2025 18:18:56 +0000 (19:18 +0100)
quickjs.c

index af1bddfdc9d2f8fa88fd5cccb16e4da09cc711f9..3e88d7b9f703c6c019df4db84cd8b16b81b16404 100644 (file)
--- a/quickjs.c
+++ b/quickjs.c
@@ -29957,6 +29957,7 @@ static int js_create_module_bytecode_function(JSContext *ctx, JSModuleDef *m)
 
     if (JS_IsException(func_obj))
         return -1;
+    m->func_obj = func_obj;
     b = JS_VALUE_GET_PTR(bfunc);
     func_obj = js_closure2(ctx, func_obj, b, NULL, NULL, TRUE, m);
     if (JS_IsException(func_obj)) {
@@ -29964,7 +29965,6 @@ static int js_create_module_bytecode_function(JSContext *ctx, JSModuleDef *m)
         JS_FreeValue(ctx, func_obj);
         return -1;
     }
-    m->func_obj = func_obj;
     return 0;
 }