Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repair resource leaks in multiple components #232

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/rbus/rbus_subscriptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion src/rtmessage/rtrouteBase.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}

Expand Down
Loading