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:
33b4055
)
libudev: avoid leak during realloc failure
author
Mauro Dreissig
<mukadr@gmail.com>
Mon, 12 Nov 2012 00:07:51 +0000
(22:07 -0200)
committer
Kay Sievers
<kay@vrfy.org>
Tue, 13 Nov 2012 00:59:33 +0000
(
01:59
+0100)
src/libudev/libudev-list.c
patch
|
blob
|
history
diff --git
a/src/libudev/libudev-list.c
b/src/libudev/libudev-list.c
index 1578aecaae13379e1ef9c7500e2c324c66f18f03..59ba69e279a2d6edeb180194e37b360f06739e27 100644
(file)
--- 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) {
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;
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;
}
free(entry->name);
free(entry->value);
free(entry);
return NULL;
}
+ list->entries = entries;
list->entries_max += add;
}
list->entries_max += add;
}