Bug fixes for memory leak in NSProviderMemoryCache.
authorjaesick.shin <jaesick.shin@samsung.com>
Thu, 25 Aug 2016 07:20:00 +0000 (16:20 +0900)
committerUze Choi <uzchoi@samsung.com>
Wed, 31 Aug 2016 09:33:43 +0000 (09:33 +0000)
Add free logic for memory leak in NSStorageWrite function.

Change-Id: Ifd8ef3b08cc61e798255be5f472df6e9d4e3575a
Signed-off-by: jaesick.shin <jaesick.shin@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10901
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
(cherry picked from commit 2f8564431591e37493985629ffee7a90dfbfe4f6)
Reviewed-on: https://gerrit.iotivity.org/gerrit/11035

service/notification/src/provider/NSProviderMemoryCache.c

index a03b9f830b70aaca26d865cab4bca179284f74f6..5f48500dd7bc76720e50f4830da46fb0a67b4576 100644 (file)
@@ -203,6 +203,8 @@ NSResult NSStorageWrite(NSCacheList * list, NSCacheElement * newObj)
         if (it)\r
         {\r
             NS_LOG(DEBUG, "already registered for topic name");\r
+            OICFree(topicData->topicName);\r
+            OICFree(topicData);\r
             pthread_mutex_unlock(&NSCacheMutex);\r
             return NS_FAIL;\r
         }\r
@@ -217,6 +219,8 @@ NSResult NSStorageWrite(NSCacheList * list, NSCacheElement * newObj)
         if (it)\r
         {\r
             NS_LOG(DEBUG, "already registered for topic name");\r
+            OICFree(topicData->topicName);\r
+            OICFree(topicData);\r
             pthread_mutex_unlock(&NSCacheMutex);\r
             return NS_FAIL;\r
         }\r
@@ -231,6 +235,8 @@ NSResult NSStorageWrite(NSCacheList * list, NSCacheElement * newObj)
         if (it)\r
         {\r
             NS_LOG(DEBUG, "already registered for topic name");\r
+            OICFree(topicData->topicName);\r
+            OICFree(topicData);\r
             pthread_mutex_unlock(&NSCacheMutex);\r
             return NS_FAIL;\r
         }\r