From 8396c58167d55f9ce0a4b93db8de7126e18bd4e8 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 28 Jan 2015 22:20:07 +0100 Subject: [PATCH] core: fix memory leak in nm_properties_changed_signal_add_property() valgrind complains (rightly): ==7702== 15 bytes in 2 blocks are definitely lost in loss record 411 of 6,278 ==7702== at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==7702== by 0x8151E6E: g_malloc (gmem.c:104) ==7702== by 0x816972E: g_strdup (gstrfuncs.c:364) ==7702== by 0x1D6671: nm_properties_changed_signal_add_property (nm-properties-changed-signal.c:235) ==7702== by 0x1AF2D5: nm_dbus_manager_register_exported_type (nm-dbus-manager.c:867) ==7702== by 0x7EE0D3D: g_type_class_ref (gtype.c:2220) ==7702== by 0x7EC9A78: g_object_new_valist (gobject.c:1928) ==7702== by 0x7EC9C10: g_object_new (gobject.c:1559) ==7702== by 0x14A5FC: new_link (nm-device-bridge.c:482) ==7702== by 0x1CF8FD: platform_link_cb (nm-manager.c:2154) ==7702== by 0x988FD8B: ffi_call_unix64 (unix64.S:76) ==7702== by 0x988F6BB: ffi_call (ffi64.c:522) --- src/nm-properties-changed-signal.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nm-properties-changed-signal.c b/src/nm-properties-changed-signal.c index d64b438378..88f975cac2 100644 --- a/src/nm-properties-changed-signal.c +++ b/src/nm-properties-changed-signal.c @@ -228,15 +228,19 @@ nm_properties_changed_signal_add_property (GType type, if (!classinfo) classinfo = nm_properties_changed_signal_setup_type (type); + g_assert (!g_hash_table_contains (classinfo->exported_props, (char *) gobject_property_name)); g_hash_table_insert (classinfo->exported_props, (char *) gobject_property_name, (char *) dbus_property_name); + if (!strchr (gobject_property_name, '_')) + return; hyphen_name = g_strdup (gobject_property_name); for (p = hyphen_name; *p; p++) { if (*p == '_') *p = '-'; } + g_assert (!g_hash_table_contains (classinfo->exported_props, hyphen_name)); g_hash_table_insert (classinfo->exported_props, hyphen_name, (char *) dbus_property_name);