[gjs] Fix various memory leaks



commit 48c979565ebe524c722c770aae58ad4c49c4f010
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri May 25 16:33:26 2012 -0400

    Fix various memory leaks
    
    Found with make valgrind-check. We should run it more often.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=676843

 gi/arg.c                |    1 +
 gi/function.c           |    1 +
 gi/object.c             |    2 ++
 gi/param.c              |    5 ++++-
 gjs-dbus/dbus-signals.c |    2 +-
 modules/dbus.c          |    2 +-
 6 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gi/arg.c b/gi/arg.c
index 40cbf2a..90182e0 100644
--- a/gi/arg.c
+++ b/gi/arg.c
@@ -2791,6 +2791,7 @@ gjs_g_arg_release_internal(JSContext  *context,
 
             if (transfer != GI_TRANSFER_CONTAINER && is_gvalue_flat_array(param_info, element_type)) {
                 g_free(arg->v_pointer);
+                g_base_info_unref(param_info);
                 return JS_TRUE;
             }
 
diff --git a/gi/function.c b/gi/function.c
index aefc6bd..195bc0d 100644
--- a/gi/function.c
+++ b/gi/function.c
@@ -1483,6 +1483,7 @@ init_cached_function_data (JSContext      *context,
             if (error->code != G_INVOKE_ERROR_SYMBOL_NOT_FOUND)
                 gjs_throw_g_error(context, error);
 
+            g_clear_error(&error);
             return FALSE;
         }
 
diff --git a/gi/object.c b/gi/object.c
index e2bd014..95109db 100644
--- a/gi/object.c
+++ b/gi/object.c
@@ -2157,6 +2157,8 @@ gjs_register_type(JSContext *cx,
                                            &type_info,
                                            0);
 
+    g_free(name);
+
     g_type_set_qdata (instance_type, gjs_is_custom_type_quark(), GINT_TO_POINTER (1));
 
     /* create a custom JSClass */
diff --git a/gi/param.c b/gi/param.c
index cea0408..f4576b0 100644
--- a/gi/param.c
+++ b/gi/param.c
@@ -377,7 +377,7 @@ param_new_internal(JSContext *cx,
         break;
     case G_TYPE_STRING:
         {
-            const gchar *default_value;
+            gchar *default_value;
 
             if (!gjs_parse_args(cx, method_name,
                                 "s", argc, argv,
@@ -386,6 +386,8 @@ param_new_internal(JSContext *cx,
 
             pspec = g_param_spec_string(prop_name, nick, blurb,
                                         default_value, flags);
+
+            g_free (default_value);
         }
         break;
     case G_TYPE_PARAM:
@@ -414,6 +416,7 @@ param_new_internal(JSContext *cx,
     JS_SET_RVAL(cx, vp, foo);
  out:
 
+    g_free(method_name);
     g_free(prop_name);
     g_free(nick);
     g_free(blurb);
diff --git a/gjs-dbus/dbus-signals.c b/gjs-dbus/dbus-signals.c
index c722148..b8f3561 100644
--- a/gjs-dbus/dbus-signals.c
+++ b/gjs-dbus/dbus-signals.c
@@ -811,7 +811,7 @@ unwatch_signal(DBusBusType                  bus_type,
                                    handler,
                                    data)) {
             GjsSignalWatcher *watcher = list->data;
-            pending_signal_watchers = g_slist_remove_link(pending_signal_watchers,
+            pending_signal_watchers = g_slist_delete_link(pending_signal_watchers,
                                                           list);
 
             if (weak != NULL)
diff --git a/modules/dbus.c b/modules/dbus.c
index ef64ded..92bfd2e 100644
--- a/modules/dbus.c
+++ b/modules/dbus.c
@@ -109,7 +109,7 @@ gjs_js_pop_current_message(void)
 {
     g_assert(_gjs_current_dbus_messages != NULL);
 
-    _gjs_current_dbus_messages = g_slist_remove_link(_gjs_current_dbus_messages,
+    _gjs_current_dbus_messages = g_slist_delete_link(_gjs_current_dbus_messages,
                                                      _gjs_current_dbus_messages);
 }
 



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