From b86647a85df3b155620376d4eb74dc457b1bbf16 Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Thu, 8 Dec 2022 16:06:39 +0100 Subject: [PATCH] mtree reader: check __archive_rb_tree_find_node() for NULL return Reported by: GitHub CodeQL Code Scanning Alert: 190 --- libarchive/archive_read_support_format_mtree.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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; + } } } -- 2.47.2