diff options
author | Mauro Dreissig <mukadr@gmail.com> | 2012-11-11 22:07:51 -0200 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2012-11-13 01:59:33 +0100 |
commit | cf2292f5ac87087f57dbd632a25a332c9d194ebf (patch) | |
tree | 3a8d4072e38090149e06134a3d92e5fc891177b6 /src | |
parent | 33b40551236a6c0c323226b78f1b1e5751a95ff5 (diff) |
libudev: avoid leak during realloc failure
Diffstat (limited to 'src')
-rw-r--r-- | src/libudev/libudev-list.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libudev/libudev-list.c b/src/libudev/libudev-list.c index 1578aecaae..59ba69e279 100644 --- a/src/libudev/libudev-list.c +++ b/src/libudev/libudev-list.c @@ -185,18 +185,20 @@ struct udev_list_entry *udev_list_entry_add(struct udev_list *list, const char * if (list->unique) { /* allocate or enlarge sorted array if needed */ if (list->entries_cur >= list->entries_max) { + struct udev_list_entry **entries; unsigned int add; add = list->entries_max; if (add < 1) add = 64; - list->entries = realloc(list->entries, (list->entries_max + add) * sizeof(struct udev_list_entry *)); - if (list->entries == NULL) { + entries = realloc(list->entries, (list->entries_max + add) * sizeof(struct udev_list_entry *)); + if (entries == NULL) { free(entry->name); free(entry->value); free(entry); return NULL; } + list->entries = entries; list->entries_max += add; } |