Skip to content

Commit

Permalink
ares__read_line: free buf on realloc failure
Browse files Browse the repository at this point in the history
  • Loading branch information
jhrozek committed Nov 6, 2014
1 parent 4535783 commit bba4dc5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ares__read_line.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
/* Allocate more space. */
newbuf = realloc(*buf, *bufsize * 2);
if (!newbuf)
return ARES_ENOMEM;
{
free(*buf);
return ARES_ENOMEM;
}
*buf = newbuf;
*bufsize *= 2;
}
Expand Down

0 comments on commit bba4dc5

Please sign in to comment.