buffer: add an assert for last_with_datap to suppress static analyzer

../buffer.c:2231:6: warning: Access to field 'flags' results in a dereference of a null pointer
          if (CHAIN_SPACE_LEN(*firstchainp) == 0) {
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../buffer.c:130:30: note: expanded from macro 'CHAIN_SPACE_LEN'
  #define CHAIN_SPACE_LEN(ch) ((ch)->flags & EVBUFFER_IMMUTABLE ? \

(cherry picked from commit f83ac92da9fff789135d1e5b9050653cf7fdb517)
This commit is contained in:
Azat Khuzhin 2018-10-28 15:16:24 +03:00 committed by Azat Khuzhin
parent 2ad11022fe
commit 5e439e50d3
No known key found for this signature in database
GPG Key ID: B86086848EF8686D

View File

@ -2228,11 +2228,13 @@ evbuffer_read_setup_vecs_(struct evbuffer *buf, ev_ssize_t howmuch,
so_far = 0;
/* Let firstchain be the first chain with any space on it */
firstchainp = buf->last_with_datap;
EVUTIL_ASSERT(*firstchainp);
if (CHAIN_SPACE_LEN(*firstchainp) == 0) {
firstchainp = &(*firstchainp)->next;
}
chain = *firstchainp;
EVUTIL_ASSERT(chain);
for (i = 0; i < n_vecs_avail && so_far < (size_t)howmuch; ++i) {
size_t avail = (size_t) CHAIN_SPACE_LEN(chain);
if (avail > (howmuch - so_far) && exact)