resource-directory: free unusued endpoints 69/22069/10
authorPhilippe Coval <philippe.coval@osg.samsung.com>
Tue, 22 Aug 2017 08:56:42 +0000 (10:56 +0200)
committerUze Choi <uzchoi@samsung.com>
Thu, 19 Oct 2017 07:07:47 +0000 (07:07 +0000)
Fix ~2Kb MLK in rd_client.c:

  2,208 bytes in 1 blocks are definitely lost in loss record 1,056 of 1,061

  oic_malloc.c:102: OICCalloc
  cainterfacecontroller.c:643: CAGetNetworkInfo
  canetworkconfigurator.c:297: CAGetNetworkInformationInternal
  caconnectivitymanager.c:298: CAGetNetworkInformation
  rd_client.c:266: RDPublishPayloadCreate
  rd_client.c:383: OCRDPublishWithDeviceId
  rd_client.c:139: OCRDPublish
  rdtests.cpp:253: RDTests_RDPublishMultipleResources_Test::TestBody()

It was detected in:
https://gerrit.iotivity.org/gerrit/#/c/22005/

Bug: https://jira.iotivity.org/browse/IOT-1684
Change-Id: I5c59f998a5b1f616fbcde27d3a215694c5bd0422
Origin: https://gerrit.iotivity.org/gerrit/#/c/22051/
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/22051
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Larry Sachs <larry.j.sachs@intel.com>
Reviewed-by: Mats Wichmann <mats@linux.com>
Reviewed-by: Habib Virji <habib.virji@samsung.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
(cherry picked from commit 3a7fb5418f8276d80bf8d83ba2db1c0dd6cfb665)

resource/csdk/resource-directory/src/rd_client.c

index a7d9dcb..a06d1b8 100644 (file)
@@ -307,6 +307,7 @@ static OCRepPayload *RDPublishPayloadCreate(const unsigned char *id,
                 dim[0] = k;
                 OCRepPayloadSetPropObjectArrayAsOwner(links[j], OC_RSRVD_ENDPOINTS, eps, dim);
             }
+            OICFreeAndSetToNull((void*) &caEps);
         }
     }
 
@@ -314,7 +315,7 @@ static OCRepPayload *RDPublishPayloadCreate(const unsigned char *id,
     result = OC_STACK_OK;
 
 exit:
-    OICFree(caEps);
+    OICFreeAndSetToNull((void*) &caEps);
     if (OC_STACK_OK != result)
     {
         OCRepPayloadDestroy(rdPayload);