Update snapshot(2017-12-06)
[platform/upstream/iotivity.git] / resource / csdk / resource-directory / src / RDClient.cpp
index 36140bd..cc1dfc0 100644 (file)
@@ -32,6 +32,7 @@
 #include "OCPlatform.h"
 #include "OCException.h"
 #include "ocpayload.h"
+#include "oic_malloc.h"
 
 using namespace OC;
 
@@ -88,10 +89,21 @@ OCStackApplicationResult publishResourceToRDCallback(void* ctx, OCDoHandle /*han
                     char *uri = NULL;
                     OCRepPayloadGetPropString(links[i], OC_RSRVD_HREF, &uri);
                     OCResourceHandle handle = OCGetResourceHandleAtUri(uri);
+
                     int64_t ins = 0;
                     OCRepPayloadGetPropInt(links[i], OC_RSRVD_INS, &ins);
                     OCBindResourceInsToResource(handle, ins);
+
+                    OICFree(uri);
+                }
+
+                // Free links
+                size_t count = calcDimTotal(dimensions);
+                for (size_t k = 0; k < count; k++)
+                {
+                    OCRepPayloadDestroy(links[k]);
                 }
+                OICFree(links);
             }
             OCRepresentation rep = parseRDResponseCallback(clientResponse);
             std::thread exec(context->callback, rep, clientResponse->result);