diff options
author | Phillip Lougher <phillip@squashfs.org.uk> | 2014-04-18 04:07:11 +0100 |
---|---|---|
committer | Phillip Lougher <phillip@squashfs.org.uk> | 2014-04-18 04:07:11 +0100 |
commit | 85b93db36201f47577f568cc00e3b57d6e762124 (patch) | |
tree | 8768a255c54e87d644dac7395d4cca403f3305d5 | |
parent | 8456ad7f373479f0e1b06f077c663f052f50dc49 (diff) | |
download | squashfs-tools-85b93db36201f47577f568cc00e3b57d6e762124.tar.gz |
unsquashfs: remove_free_list(), silence bogus NULL pointer dereference
Static analysis reports a NULL pointer dereference in
remove_free_list().
This is because static analysis is too stupid to realise
if free_prev and free_next are both not NULL, then both
pointers are guaranteed to contain values. It instead
determines a not checked for situation where one pointer can
contain a value and the other contains NULL, and flags this
as a potential NULL pointer dereference, even though this
situation cannot occur.
Even though it is strictly unnecessary, it is easily to silence
static analysers by changing the check to be free_prev == NULL ||
free_next == NULL. The fact being it is sufficient for either
pointer to be NULL to know we have an empty list.
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
-rw-r--r-- | squashfs-tools/unsquashfs.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/squashfs-tools/unsquashfs.c b/squashfs-tools/unsquashfs.c index 322b964..0c22217 100644 --- a/squashfs-tools/unsquashfs.c +++ b/squashfs-tools/unsquashfs.c @@ -285,7 +285,7 @@ void insert_free_list(struct cache *cache, struct cache_entry *entry) /* Called with the cache mutex held */ void remove_free_list(struct cache *cache, struct cache_entry *entry) { - if(entry->free_prev == NULL && entry->free_next == NULL) + if(entry->free_prev == NULL || entry->free_next == NULL) /* not in free list */ return; else if(entry->free_prev == entry && entry->free_next == entry) { |