]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
scan-build: check impossible null-pointer case in buffers.c
authorNick Mathewson <nickm@torproject.org>
Sat, 19 Apr 2014 00:28:46 +0000 (20:28 -0400)
committerNick Mathewson <nickm@torproject.org>
Sat, 19 Apr 2014 00:28:46 +0000 (20:28 -0400)
When maintaining buffer freelists, we don't skip more than there
are, so (*chp) can't be null to begin with.  scan-build has no way
to know that.

src/or/buffers.c

index 012ced6d323cfd87607be368b53ca6ce1b40a1e4..fb186081cf02e3e6ed8565649459274548ab8946 100644 (file)
@@ -322,7 +322,7 @@ buf_shrink_freelists(int free_all)
       chunk_t **chp = &freelists[i].head;
       chunk_t *chunk;
       while (n_to_skip) {
-        if (! (*chp)->next) {
+        if (!(*chp) || ! (*chp)->next) {
           log_warn(LD_BUG, "I wanted to skip %d chunks in the freelist for "
                    "%d-byte chunks, but only found %d. (Length %d)",
                    orig_n_to_skip, (int)freelists[i].alloc_size,