[gjs] native.c: Fix memory lookup in module importer



commit 56b6e19b4f1b18630a815175b2c57e3e30a97636
Author: Colin Walters <walters verbum org>
Date:   Thu May 5 15:39:03 2011 -0400

    native.c: Fix memory lookup in module importer
    
    ==13839== 257 bytes in 69 blocks are definitely lost in loss record 4,712 of 5,648
    ==13839==    at 0x4006D69: malloc (vg_replace_malloc.c:236)
    ==13839==    by 0x5191BCA: standard_malloc (gmem.c:88)
    ==13839==    by 0x519201F: g_malloc (gmem.c:164)
    ==13839==    by 0x41AD610: gjs_string_get_ascii (jsapi-util-string.c:279)
    ==13839==    by 0x41ADBDF: ??? (native.c:100)
    ==13839==    by 0x41ADC37: ??? (native.c:119)
    ==13839==    by 0x41ADE3E: gjs_is_registered_native_module (native.c:171)
    ==13839==    by 0x41A96A8: ??? (importer.c:518)
    ==13839==    by 0x4280F86: CallResolveOp(JSContext*, JSObject*, JSObject*, int, unsigned int, JSObject**, JSProperty**, bool*) (in /src/build/jhbuild/lib/libmozjs185.so.1.0.0)
    ==13839==    by 0x4289621: js_GetPropertyHelper(JSContext*, JSObject*, int, unsigned int, js::Value*) (in /src/build/jhbuild/lib/libmozjs185.so.1.0.0)
    ==13839==    by 0x4257CEE: js::Interpret(JSContext*, JSStackFrame*, unsigned int, JSInterpMode) (in /src/build/jhbuild/lib/libmozjs185.so.1.0.0)
    ==13839==    by 0x426A07F: js::RunScript(JSContext*, JSScript*, JSStackFrame*) (in /src/build/jhbuild/lib/libmozjs185.so.1.0.0)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=649499

 gjs/native.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/gjs/native.c b/gjs/native.c
index 1bb4faa..8a08112 100644
--- a/gjs/native.c
+++ b/gjs/native.c
@@ -113,13 +113,14 @@ lookup_native_module(JSContext  *context,
 
     module_id = g_string_new(name);
     while (parent != NULL) {
-        const char *name;
+        char *name;
         jsval tmp;
 
         name = get_module_name(context, parent, &tmp);
         if (name != NULL) {
             g_string_prepend_c(module_id, '.');
             g_string_prepend(module_id, name);
+            g_free(name);
         }
 
         /* Move up to parent */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]