Skip to content

Commit

Permalink
ipc: fix potential memory leak in send()
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Sep 7, 2024
1 parent f5e408a commit dc9e8bc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ipc/sockio.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,16 @@ ssize_t send(Thread *t, int sd, const void *buffer, size_t len, int flags) {

size_t *newlen = realloc(peer->inboundLen, (peer->inboundCount+1) * sizeof(size_t));

if(!newlen) {
free(newlist);
socketRelease();
return -ENOBUFS;
}

void *message = malloc(len);
if(!message) {
free(newlist);
free(newlen);
socketRelease();
return -ENOBUFS;
}
Expand Down

0 comments on commit dc9e8bc

Please sign in to comment.