mirror of
https://github.com/cuberite/libevent.git
synced 2025-08-04 09:46:23 -04:00
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:
parent
2ad11022fe
commit
5e439e50d3
2
buffer.c
2
buffer.c
@ -2228,11 +2228,13 @@ evbuffer_read_setup_vecs_(struct evbuffer *buf, ev_ssize_t howmuch,
|
|||||||
so_far = 0;
|
so_far = 0;
|
||||||
/* Let firstchain be the first chain with any space on it */
|
/* Let firstchain be the first chain with any space on it */
|
||||||
firstchainp = buf->last_with_datap;
|
firstchainp = buf->last_with_datap;
|
||||||
|
EVUTIL_ASSERT(*firstchainp);
|
||||||
if (CHAIN_SPACE_LEN(*firstchainp) == 0) {
|
if (CHAIN_SPACE_LEN(*firstchainp) == 0) {
|
||||||
firstchainp = &(*firstchainp)->next;
|
firstchainp = &(*firstchainp)->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
chain = *firstchainp;
|
chain = *firstchainp;
|
||||||
|
EVUTIL_ASSERT(chain);
|
||||||
for (i = 0; i < n_vecs_avail && so_far < (size_t)howmuch; ++i) {
|
for (i = 0; i < n_vecs_avail && so_far < (size_t)howmuch; ++i) {
|
||||||
size_t avail = (size_t) CHAIN_SPACE_LEN(chain);
|
size_t avail = (size_t) CHAIN_SPACE_LEN(chain);
|
||||||
if (avail > (howmuch - so_far) && exact)
|
if (avail > (howmuch - so_far) && exact)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user