Newly created group's memory should be allocated using g_try_malloc0 70/59370/1
authorNishant Chaprana <n.chaprana@samsung.com>
Mon, 15 Feb 2016 06:26:19 +0000 (11:56 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Mon, 15 Feb 2016 06:26:19 +0000 (11:56 +0530)
This patch allocates newly created group's memory using g_try_malloc0
because the memory for group is freed using g_free() in wfd_destroy_group().
If the allocator and destructor funciton of memory are different
then chances of memory corruption are present because glib maintains its own
memory allocation pool.

Change-Id: I995376f9d1349df06ca3866ac7caab4b25f88bba
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
packaging/wifi-direct-manager.spec
src/wifi-direct-group.c

index 004fd58..c506704 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          wifi-direct-manager
 Summary:       Wi-Fi Direct manger
-Version:       1.2.130
+Version:       1.2.131
 Release:       1
 Group:      Network & Connectivity/Wireless
 License:    Apache-2.0
index fb5b98f..ecee9d2 100755 (executable)
@@ -71,7 +71,7 @@ wfd_group_s *wfd_create_group(void *data, wfd_oem_event_s *group_info)
        }
 
        errno = 0;
-       group = (wfd_group_s*) calloc(1, sizeof(wfd_group_s));
+       group = (wfd_group_s*) g_try_malloc0(sizeof(wfd_group_s));
        if (!group) {
                WDS_LOGE("Failed to allocate memory for group. [%s]", strerror(errno));
                __WDS_LOG_FUNC_EXIT__;