Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Med: list_ticket: fix a memleak in case of buffer too small
Note that such a case seems impossible but there may be other issues
that will add up (see, e.g., reckless snprintf use pointed out with
ClusterLabs/pacemaker#810, something should
eventually be reflected here as well).

Discovered-by: static analysis/Coverity
  • Loading branch information
jnpkrn committed May 13, 2016
commit 153f56cf83f2f236d52318c652911ab72bc381b6
4 changes: 3 additions & 1 deletion src/ticket.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,10 @@ int list_ticket(char **pdata, unsigned int *len)
cp += snprintf(cp, alloc - (cp - data), "\n");
}

if (alloc - (cp - data) <= 0)
if (alloc - (cp - data) <= 0) {
free(data);
return -ENOMEM;
}
}

*pdata = data;
Expand Down