p2p: Fix not freeing server_data in free_server_data
authorSzymon Janc <szymon.janc@tieto.com>
Wed, 8 Aug 2012 07:42:06 +0000 (09:42 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 14 Aug 2012 15:59:14 +0000 (17:59 +0200)
Free server_data when clearing servers list. This fix following issue
reported by valgrind:

84 bytes in 3 blocks are definitely lost in loss record 167 of 210
   at 0x402BE68: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
   by 0x4095C5A: ??? (in /lib/i386-linux-gnu/libglib-2.0.so.0.3306.0)
   by 0x40961DC: g_try_malloc0 (in /lib/i386-linux-gnu/libglib-2.0.so.0.3306.0)
   by 0x8056853: p2p_listen (p2p.c:247)
   by 0x407FA21: g_hash_table_foreach (in /lib/i386-linux-gnu/libglib-2.0.so.0.3306.0)
   by 0x805BA2F: __near_adapter_listen (adapter.c:1048)
   by 0x805C64D: near_device_driver_register (device.c:461)
   by 0x80567E2: p2p_init (p2p.c:374)
   by 0x805E317: __near_plugin_init (plugin.c:180)
   by 0x804E0E1: main (main.c:214)

plugins/p2p.c

index c324faf..f6352a1 100644 (file)
@@ -133,6 +133,8 @@ static void free_server_data(gpointer data)
        DBG("Closing server socket");
 
        close(server_data->fd);
+
+       g_free(server_data);
 }
 
 static gboolean p2p_listener_event(GIOChannel *channel, GIOCondition condition,