From 29d10c76f9b5d79c9d156730f6b5dc7419412526 Mon Sep 17 00:00:00 2001 From: Colin Percival Date: Fri, 23 May 2008 05:07:22 +0000 Subject: [PATCH] The value le->name cannot be NULL when we're freeing an entry in the hardlink table for two reasons: 1. If le->name is set to NULL, the structure le won't be inserted into the table; 2. Even if le somehow did manage to get into the table with le->name equal to NULL, we would die when we dereferenced le->null before we could get to the point of freeing the entry. Remove the unnecessary "if (le->name != NULL)" test and just free the pointer. Found by: Coverity Prevent --- usr.bin/tar/write.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usr.bin/tar/write.c b/usr.bin/tar/write.c index 8fe0530539c2..9b3f39bc1c16 100644 --- a/usr.bin/tar/write.c +++ b/usr.bin/tar/write.c @@ -1100,8 +1100,7 @@ lookup_hardlink(struct bsdtar *bsdtar, struct archive_entry *entry, le->previous->next = le->next; if (le->next != NULL) le->next->previous = le->previous; - if (le->name != NULL) - free(le->name); + free(le->name); if (links_cache->buckets[hash] == le) links_cache->buckets[hash] = le->next; links_cache->number_entries--;