[gjs] object.c: Fix leak of parameters when handling a singleton



commit f6b003ebbda6ed50c76312d5347d9296675784ab
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Thu Jan 12 18:05:37 2012 -0500

    object.c: Fix leak of parameters when handling a singleton
    
    When we find an existing JSObject, don't forget to free the
    parameters we passed to g_object_newv().

 gi/object.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
---
diff --git a/gi/object.c b/gi/object.c
index d7caefb..572ecd7 100644
--- a/gi/object.c
+++ b/gi/object.c
@@ -703,6 +703,7 @@ GJS_NATIVE_CONSTRUCTOR_DECLARE(object_instance)
     }
 
     priv->gobj = g_object_newv(gtype, n_params, params);
+    free_g_params(params, n_params);
 
     if (peek_js_obj(context, priv->gobj) != NULL) {
         /* g_object_newv returned an object that's already tracked by a JS
@@ -718,8 +719,6 @@ GJS_NATIVE_CONSTRUCTOR_DECLARE(object_instance)
         goto out;
     }
 
-    free_g_params(params, n_params);
-
     g_type_query(gtype, &query);
     JS_updateMallocCounter(context, query.instance_size);
 



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