diff --git a/src/rbus/rbus_subscriptions.c b/src/rbus/rbus_subscriptions.c index 5e6636de..8f88996c 100644 --- a/src/rbus/rbus_subscriptions.c +++ b/src/rbus/rbus_subscriptions.c @@ -621,7 +621,7 @@ static void rbusSubscriptions_loadCache(rbusSubscriptions_t subscriptions) rbusBuffer_Destroy(buff); if(sub) - free(sub); + subscriptionFree(sub); if(remove(filePath) != 0) RBUSLOG_ERROR("failed to remove %s", filePath); @@ -665,7 +665,11 @@ static void rbusSubscriptions_saveCache(rbusSubscriptions_t subscriptions) { rtListItem_GetData(item, (void**)&sub); if(!sub) + { + rbusBuffer_Destroy(buff); + fclose(file); return; + } rbusBuffer_WriteStringTLV(buff, sub->listener, strlen(sub->listener)+1); rbusBuffer_WriteStringTLV(buff, sub->eventName, strlen(sub->eventName)+1); rbusBuffer_WriteInt32TLV(buff, sub->componentId); diff --git a/src/rtmessage/rtrouteBase.c b/src/rtmessage/rtrouteBase.c index f9d1c700..d832bce1 100644 --- a/src/rtmessage/rtrouteBase.c +++ b/src/rtmessage/rtrouteBase.c @@ -66,7 +66,10 @@ rtRouteBase_BindListener(char const* socket_name, int no_delay, int indefinite_r err = rtSocketStorage_FromString(&listener->local_endpoint, socket_name); if (err != RT_OK) + { + free(listener); return err; + } rtLog_Debug("binding listener:%s", socket_name); @@ -130,7 +133,7 @@ rtRouteBase_BindListener(char const* socket_name, int no_delay, int indefinite_r { rtLog_Warn("failed to set socket to listen mode. %s", rtStrError(errno)); rtRouteBase_CloseListener(listener); - free(listener); + free(listener); return RT_FAIL; }