Skip to content

Commit bba4dc5

Browse files
committed
ares__read_line: free buf on realloc failure
1 parent 4535783 commit bba4dc5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

ares__read_line.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
6161
/* Allocate more space. */
6262
newbuf = realloc(*buf, *bufsize * 2);
6363
if (!newbuf)
64-
return ARES_ENOMEM;
64+
{
65+
free(*buf);
66+
return ARES_ENOMEM;
67+
}
6568
*buf = newbuf;
6669
*bufsize *= 2;
6770
}

0 commit comments

Comments
 (0)