The AddClientCB method would delete the resourceTypeName
before it got a chance to insert it due to the logic designed
to make the free'ing consistent. This fix moves the free until
afterwards. Note that the insert method does NOT makes a copy,
so it is the responsibility of this method to free in the event
that the pointer is not captured.
Change-Id: I9c0c66cfbfb9e8d1ace5df9de372476fbf262659
Signed-off-by: Erich Keane <erich.keane@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/582
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Joseph Morrow <joseph.l.morrow@intel.com>
Reviewed-by: Sudarshan Prasad <sudarshan.prasad@intel.com>
OCFree(*token);
OCFree(*handle);
OCFree(requestUri);
- OCFree(resourceTypeName);
*handle = cbNode->handle;
}
#ifdef WITH_PRESENCE
if(method == OC_REST_PRESENCE && resourceTypeName)
- { // Amend the found or created node by adding a new resourceType to it.
+ {
+ // Amend the found or created node by adding a new resourceType to it.
return InsertResourceTypeFilter(cbNode, resourceTypeName);
}
+ else
+ {
+ OCFree(resourceTypeName);
+ }
+ #else
+ OCFree(resourceTypeName);
#endif
return OC_STACK_OK;
OC_MULTICAST_IP, nullptr, OC_WIFI, &presenceHandler));
}
- //UnsubscribePresence Test
- //We will enable it after fixing double free or corruption
- TEST(SubscribePresenceTest, DISABLED_UnsubscribePresenceWithValidHandleAndRT)
+ TEST(SubscribePresenceTest, UnsubscribePresenceWithValidHandleAndRT)
{
OCPlatform::OCPresenceHandle presenceHandle = nullptr;