Fix memory leaks in case co_context to be freed 77/70677/1 accepted/tizen/common/20160523.143930 accepted/tizen/ivi/20160524.004114 accepted/tizen/mobile/20160524.004038 accepted/tizen/tv/20160524.004108 accepted/tizen/wearable/20160524.004054 submit/tizen/20160523.014856
authorWootak Jung <wootak.jung@samsung.com>
Fri, 20 May 2016 05:55:48 +0000 (14:55 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Fri, 20 May 2016 05:55:48 +0000 (14:55 +0900)
Change-Id: Iee380f3a5c42b803ddbf21189a127d9b002a4758

packaging/libtcore.spec
src/core_object/co_context.c

index d08811a..66fd283 100644 (file)
@@ -1,6 +1,6 @@
 %define major 0
 %define minor 3
-%define patchlevel 2
+%define patchlevel 3
 
 Name:           libtcore
 Version:        %{major}.%{minor}.%{patchlevel}
index 655631a..472e424 100644 (file)
@@ -78,8 +78,53 @@ static void _free_hook(CoreObject *o)
 {
        struct private_object_data *po = NULL;
 
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_PS_CONTEXT);
+
        po = tcore_object_ref_object(o);
        if (po) {
+               unsigned int i;
+
+               if (po->apn)
+                       g_free(po->apn);
+               if (po->addr)
+                       g_free(po->addr);
+               if (po->username)
+                       g_free(po->username);
+               if (po->password)
+                       g_free(po->password);
+               if (po->dns1)
+                       g_free(po->dns1);
+               if (po->dns2)
+                       g_free(po->dns2);
+
+               if (po->ip_v6)
+                       g_free(po->ip_v6);
+               if (po->gateway_v6)
+                       g_free(po->gateway_v6);
+               if (po->dns_primary_v6)
+                       g_free(po->dns_primary_v6);
+               if (po->dns_secondary_v6)
+                       g_free(po->dns_secondary_v6);
+
+               if (po->pcscf_ipv4) {
+                       for (i = 0; i < po->pcscf_ipv4->count; i++)
+                               g_free(po->pcscf_ipv4->addr[i]);
+                       g_free(po->pcscf_ipv4);
+               }
+
+               if (po->pcscf_ipv6) {
+                       for (i = 0; i < po->pcscf_ipv6->count; i++)
+                               g_free(po->pcscf_ipv6->addr[i]);
+                       g_free(po->pcscf_ipv6);
+               }
+
+               if (po->proxy)
+                       g_free(po->proxy);
+               if (po->mmsurl)
+                       g_free(po->mmsurl);
+               if (po->profile_name)
+                       g_free(po->profile_name);
+
                free(po);
                tcore_object_link_object(o, NULL);
        }
@@ -651,7 +696,7 @@ TReturn tcore_context_set_proxy(CoreObject *o, const char *proxy)
 
        if (po->proxy) {
                g_free(po->proxy);
-               po->apn = NULL;
+               po->proxy = NULL;
        }
 
        if (proxy)