Просмотр исходного кода

libcompat: On successful realloc assign the newlist to list

Guillem Jover лет назад: 16
Родитель
Сommit
5a80ec6ce8
2 измененных файлов с 4 добавлено и 0 удалено
  1. 3 0
      debian/changelog
  2. 1 0
      lib/compat/scandir.c

+ 3 - 0
debian/changelog

@@ -27,6 +27,9 @@ dpkg (1.15.8.5) UNRELEASED; urgency=low
   * Swedish (Peter Krefting).
   * Thai (Theppitak Karoonboonyanan). Closes: #594011
 
+  [ Guillem Jover ]
+  * Fix realloc usage on compat scandir() implementation.
+
   [ Updated man page translations ]
   * French (Christian Perrier).
   * German (Helge Kreutzmann).

+ 1 - 0
lib/compat/scandir.c

@@ -74,6 +74,7 @@ scandir(const char *dir, struct dirent ***namelist,
 			newlist = realloc(list, avail * sizeof(struct dirent *));
 			if (!newlist)
 				return cleanup(d, list, used);
+			list = newlist;
 		}
 
 		m = malloc(sizeof(struct dirent) + strlen(e->d_name));