diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2008-06-18 00:47:33 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-06-18 10:10:29 +0200 |
commit | 322fc7a636296ba9a3f93912661f14c65c2af4b2 (patch) | |
tree | f2db7405fea648c19eeff7ee840398b17a9b9353 | |
parent | c986ca557ddd2c98807edbd727cda6a20b234642 (diff) |
collect: check realloc return value
-rw-r--r-- | extras/collect/collect.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/extras/collect/collect.c b/extras/collect/collect.c index feb0e75768..9fb6737d9b 100644 --- a/extras/collect/collect.c +++ b/extras/collect/collect.c @@ -53,7 +53,7 @@ static LIST_HEAD(bunch); static int debug; /* This can increase dynamically */ -static int bufsize = BUFSIZE; +static size_t bufsize = BUFSIZE; static void sig_alrm(int signo) { @@ -272,8 +272,15 @@ static int missing(int fd) ret++; } else { while (strlen(him->name)+1 >= bufsize) { + char *tmpbuf; + bufsize = bufsize << 1; - buf = realloc(buf, bufsize); + tmpbuf = realloc(buf, bufsize); + if (!tmpbuf) { + free(buf); + return -1; + } + buf = tmpbuf; } snprintf(buf, strlen(him->name)+2, "%s ", him->name); write(fd, buf, strlen(buf)); |