Fixed a crash error caused on IP network get down
authorJaewook Jung <jw0213.jung@samsung.com>
Fri, 20 Jan 2017 03:15:54 +0000 (12:15 +0900)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Thu, 26 Jan 2017 21:47:31 +0000 (21:47 +0000)
Because CAGetIPInterfaceInformation() allocates memory to
CAEndpoint_t at once, OICFree also should be called once.

Change-Id: I7cb85761e1d49e73d357928c77b364555d82c87f
Signed-off-by: Jaewook Jung <jw0213.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/16621
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
resource/csdk/connectivity/src/ip_adapter/caipadapter.c

index 9fdec6f..153b8c7 100644 (file)
@@ -206,11 +206,14 @@ static void CAUpdateStoredIPAddressInfo(CANetworkStatus_t status)
     {
         OIC_LOG(DEBUG, TAG, "IP adapter status is off. Remove the own IP address info");
 
+        CAEndpoint_t *headEp = u_arraylist_get(g_ownIpEndpointList, 0);
+        OICFree(headEp);
+        headEp = NULL;
+
         uint32_t len = u_arraylist_length(g_ownIpEndpointList);
         for (uint32_t i = len; i > 0; i--)
         {
-            CAEndpoint_t *ep = u_arraylist_remove(g_ownIpEndpointList, i - 1);
-            OICFree(ep);
+            u_arraylist_remove(g_ownIpEndpointList, i - 1);
         }
     }
 }