pidgin/pidgin

Fix leak in Status Manager dialog

14 months ago, Elliott Sales de Andrade
eafcc5051015
Parents e431d160e3a1
Children b8f686f4d43a
Fix leak in Status Manager dialog

Fix the leak of the GObject wrapper
```
580 (72 direct, 508 indirect) bytes in 3 blocks are definitely lost in loss record 30,987 of 34,328
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4980168: g_malloc (gmem.c:130)
by 0x4997AB5: g_slice_alloc (gslice.c:1074)
by 0x49980EC: g_slice_alloc0 (gslice.c:1100)
by 0x4DDF04B: g_type_create_instance (gtype.c:1913)
by 0x4DC4C1F: g_object_new_internal (gobject.c:2228)
by 0x4DC6247: g_object_new_with_properties (gobject.c:2391)
by 0x4DC6FF0: g_object_new (gobject.c:2037)
by 0x48B79DF: pidgin_status_manager_add (pidginstatusmanager.c:138)
by 0x48B7B2A: pidgin_status_manager_populate_helper (pidginstatusmanager.c:158)
by 0x496801F: g_list_foreach (glist.c:1092)
by 0x48B7B74: pidgin_status_manager_refresh (pidginstatusmanager.c:169)
```

Testing Done:
Ran valgrind, opened Statuses and an editor for a status, and the leak was gone.

Reviewed at https://reviews.imfreedom.org/r/2301/
--- a/pidgin/pidginstatusmanager.c Tue Feb 28 03:23:06 2023 -0600
+++ b/pidgin/pidginstatusmanager.c Tue Feb 28 03:24:02 2023 -0600
@@ -144,9 +144,10 @@
g_object_set_data_full(wrapper, "type", g_strdup(type), g_free);
g_object_set_data_full(wrapper, "message", g_strdup(message), g_free);
- g_free(message);
+ g_list_store_append(manager->model, wrapper);
- g_list_store_append(manager->model, wrapper);
+ g_free(message);
+ g_object_unref(wrapper);
}
static void
@@ -319,9 +320,12 @@
if(editor == widget) {
/* It is, so set it back to NULL to remove it from the wrapper. */
g_object_set_data(wrapper, "editor", NULL);
+ g_object_unref(wrapper);
break;
}
+
+ g_object_unref(wrapper);
}
}