]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
mtree reader: check __archive_rb_tree_find_node() for NULL return
authorMartin Matuska <martin@matuska.de>
Thu, 8 Dec 2022 15:06:39 +0000 (16:06 +0100)
committerMartin Matuska <martin@matuska.de>
Thu, 8 Dec 2022 15:07:07 +0000 (16:07 +0100)
Reported by: GitHub CodeQL
Code Scanning Alert: 190

libarchive/archive_read_support_format_mtree.c

index 22759ab52e9f6a8ff1a29c0bcdf8e06093a6e705..2bc3ba066c3baef4692998e5d6f019a280640c3e 100644 (file)
@@ -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;
+                       }
                }
        }