summaryrefslogtreecommitdiff
path: root/libudev
diff options
context:
space:
mode:
authorFlorian Zumbiehl <florz@florz.de>2009-08-29 16:25:47 +0200
committerKay Sievers <kay.sievers@vrfy.org>2009-08-29 16:25:47 +0200
commit72c0373f795a5c326e6bd0f7469601f492124d70 (patch)
treedb43fbf510fc068d559272f4f7537b9e21193fac /libudev
parentf46b9c2628a4d28381ab297e699d9a0530a9e945 (diff)
util_lookup_group(): fix memory leak if realloc() fails
Diffstat (limited to 'libudev')
-rw-r--r--libudev/libudev-util-private.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libudev/libudev-util-private.c b/libudev/libudev-util-private.c
index 5b5ecb1f50..b33ee79d6b 100644
--- a/libudev/libudev-util-private.c
+++ b/libudev/libudev-util-private.c
@@ -154,9 +154,12 @@ gid_t util_lookup_group(struct udev *udev, const char *group)
buf = NULL;
gid = 0;
for (;;) {
- buf = realloc(buf, buflen);
- if (!buf)
+ char *newbuf;
+
+ newbuf = realloc(buf, buflen);
+ if (!newbuf)
break;
+ buf = newbuf;
errno = getgrnam_r(group, &grbuf, buf, buflen, &gr);
if (gr != NULL) {
gid = gr->gr_gid;