Fix memory leak in OCDoResource
authorSudarsana Nagineni <sudarsana.nagineni@intel.com>
Tue, 30 Aug 2016 11:01:11 +0000 (14:01 +0300)
committerZiran Sun <ziran.sun@samsung.com>
Tue, 20 Sep 2016 13:33:39 +0000 (13:33 +0000)
OCDoResource was leaking the resourceUri when the presence enabled,
so this patch fixes the issue by freeing the resourceUri before
re-assigning the presence uri.

Change-Id: I2fc2a6c42e5079e67cc72a8be22803bf7157ad36
Signed-off-by: Sudarsana Nagineni <sudarsana.nagineni@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11145
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Ziran Sun <ziran.sun@samsung.com>
resource/csdk/stack/src/ocstack.c

index 7042ad9..23cdfb6 100644 (file)
@@ -2826,6 +2826,10 @@ OCStackResult OCDoResource(OCDoHandle *handle,
         // Assign full presence uri as coap://ip:port/oic/ad to add to callback list.
         // Presence notification will form a canonical uri to
         // look for callbacks into the application.
+        if (resourceUri)
+        {
+            OICFree(resourceUri);
+        }
         resourceUri = presenceUri;
     }
 #endif