Browse Source

libcompat: Do not run qsort over the scandir list if it is NULL

Warned-by: coverity
Guillem Jover 12 years ago
parent
commit
75a93afbe5
2 changed files with 2 additions and 1 deletions
  1. 1 0
      debian/changelog
  2. 1 1
      lib/compat/scandir.c

+ 1 - 0
debian/changelog

@@ -7,6 +7,7 @@ dpkg (1.17.11) UNRELEASED; urgency=low
   * Update some dpkg git URLs to the new and newer (cgit switch) scheme.
   * Changes to libcompat:
     - Make the library testable.
+    - Do not run qsort() over the scandir() list if it is NULL.
 
   [ Updated programs translations ]
   * Danish (Joe Dalton). Closes: #754127

+ 1 - 1
lib/compat/scandir.c

@@ -90,7 +90,7 @@ scandir(const char *dir, struct dirent ***namelist,
 
 	closedir(d);
 
-	if (cmp != NULL)
+	if (list != NULL && cmp != NULL)
 		qsort(list, used, sizeof(struct dirent *), cmp);
 
 	*namelist = list;