[tor-commits] [tor/master] scan-build: check impossible null-pointer case in buffers.c

nickm at torproject.org nickm at torproject.org
Fri Apr 25 05:30:23 UTC 2014


commit 41a8930fa1202b882687c0c3a328307b480934b5
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Apr 18 20:28:46 2014 -0400

    scan-build: check impossible null-pointer case in buffers.c
    
    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 |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/or/buffers.c b/src/or/buffers.c
index 012ced6..fb18608 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -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,





More information about the tor-commits mailing list