chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c986ca5
)
collect: check realloc return value
author
Tobias Klauser
<tklauser@distanz.ch>
Tue, 17 Jun 2008 22:47:33 +0000
(
00:47
+0200)
committer
Kay Sievers
<kay.sievers@vrfy.org>
Wed, 18 Jun 2008 08:10:29 +0000
(10:10 +0200)
extras/collect/collect.c
patch
|
blob
|
history
diff --git
a/extras/collect/collect.c
b/extras/collect/collect.c
index feb0e7576871551e6e5984c32a0e43d51a79b9dc..9fb6737d9b4d6af94877d5b2efdb39c96ad7053e 100644
(file)
--- 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 debug;
/* This can increase dynamically */
-static
in
t bufsize = BUFSIZE;
+static
size_
t bufsize = BUFSIZE;
static void sig_alrm(int signo)
{
static void sig_alrm(int signo)
{
@@
-272,8
+272,15
@@
static int missing(int fd)
ret++;
} else {
while (strlen(him->name)+1 >= bufsize) {
ret++;
} else {
while (strlen(him->name)+1 >= bufsize) {
+ char *tmpbuf;
+
bufsize = bufsize << 1;
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));
}
snprintf(buf, strlen(him->name)+2, "%s ", him->name);
write(fd, buf, strlen(buf));