SHA256
1
0
forked from pool/systemd
systemd/1011-libudev-avoid-leak-during-realloc-failure.patch

37 lines
1.6 KiB
Diff
Raw Normal View History

From cf2292f5ac87087f57dbd632a25a332c9d194ebf Mon Sep 17 00:00:00 2001
From: Mauro Dreissig <mukadr@gmail.com>
Date: Sun, 11 Nov 2012 22:07:51 -0200
Subject: [PATCH] libudev: avoid leak during realloc failure
---
src/libudev/libudev-list.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
Index: systemd-195/src/libudev/libudev-list.c
===================================================================
--- systemd-195.orig/src/libudev/libudev-list.c
+++ systemd-195/src/libudev/libudev-list.c
@@ -177,18 +177,20 @@ struct udev_list_entry *udev_list_entry_
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;
}