From: Martin Matuska Date: Thu, 8 Dec 2022 15:06:39 +0000 (+0100) Subject: mtree reader: check __archive_rb_tree_find_node() for NULL return X-Git-Tag: v3.6.2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b86647a85df3b155620376d4eb74dc457b1bbf16;p=thirdparty%2Flibarchive.git mtree reader: check __archive_rb_tree_find_node() for NULL return Reported by: GitHub CodeQL Code Scanning Alert: 190 --- diff --git a/libarchive/archive_read_support_format_mtree.c b/libarchive/archive_read_support_format_mtree.c index 22759ab52..2bc3ba066 100644 --- a/libarchive/archive_read_support_format_mtree.c +++ b/libarchive/archive_read_support_format_mtree.c @@ -994,9 +994,11 @@ process_add_entry(struct archive_read *a, struct mtree *mtree, struct mtree_entry *alt; alt = (struct mtree_entry *)__archive_rb_tree_find_node( &mtree->rbtree, entry->name); - while (alt->next_dup) - alt = alt->next_dup; - alt->next_dup = entry; + if (alt != NULL) { + while (alt->next_dup) + alt = alt->next_dup; + alt->next_dup = entry; + } } }