Skip to content

Commit e5e631f

Browse files
committed
lib: do not call qsort with NULL
found with -fsanitize=undefined: transaction_files.c:890:8: runbime error: null pointer passed as argument 1, which is declared to never be null /usr/include/stdlib.h:971:30: note: nonnull attribute specified here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior transaction_files.c:890:8
1 parent a31c60f commit e5e631f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/transaction_files.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,8 @@ xbps_transaction_files(struct xbps_handle *xhp, xbps_object_iterator_t iter)
887887
* Sort items by path length, to make it easier to find files in
888888
* directories.
889889
*/
890-
qsort(items, itemsidx, sizeof (struct item *), pathcmp);
890+
if (items)
891+
qsort(items, itemsidx, sizeof (struct item *), pathcmp);
891892

892893
if (chdir(xhp->rootdir) == -1) {
893894
rv = errno;

0 commit comments

Comments
 (0)