summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Matuska <martin@matuska.de>2022-12-08 16:06:39 +0100
committerMartin Matuska <martin@matuska.de>2022-12-08 16:07:07 +0100
commitb86647a85df3b155620376d4eb74dc457b1bbf16 (patch)
tree5d24f705b0b51dcd22ca76213eb4070856e90ff4
parent92d2835fed1e9be1e6fd49949bdef917df577274 (diff)
downloadlibarchive-b86647a85df3b155620376d4eb74dc457b1bbf16.tar.gz
mtree reader: check __archive_rb_tree_find_node() for NULL return
Reported by: GitHub CodeQL Code Scanning Alert: 190
-rw-r--r--libarchive/archive_read_support_format_mtree.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libarchive/archive_read_support_format_mtree.c b/libarchive/archive_read_support_format_mtree.c
index 22759ab5..2bc3ba06 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;
+ }
}
}