Skip to content

Commit

Permalink
libterminus: fix memleak on error
Browse files Browse the repository at this point in the history
Problem: An error path in pty_client_create() could lead to a mem-leak.

Solution: Destroy memory on error.
  • Loading branch information
chu11 committed Jun 28, 2021
1 parent 22b7493 commit bdd80db
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/common/libterminus/pty.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,13 @@ static struct pty_client *pty_client_create (const flux_msg_t *msg)
if (!(c = calloc (1, sizeof (*c))))
return NULL;
if (flux_msg_get_route_first (msg, &uuid) < 0)
return NULL;
goto error;
c->req = flux_msg_incref (msg);
c->uuid = uuid;
return c;
error:
pty_client_destroy (c);
return NULL;
}

static struct pty_client *pty_client_find (struct flux_pty *pty,
Expand Down

0 comments on commit bdd80db

Please sign in to comment.