mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
bufferevent_filter: do not allow upcast() to return NULL (fixes infer warning)
/src/le/libevent/bufferevent_filter.c:234: error: Null Dereference pointer `bevf` last assigned on line 231 could be null and is dereferenced at line 234, column 6. 232. EVUTIL_ASSERT(bevf); 233. 234. if (bevf->bev.options & BEV_OPT_CLOSE_ON_FREE) { ^ 235. /* Yes, there is also a decref in bufferevent_decref_. 236. * That decref corresponds to the incref when we set
This commit is contained in:
parent
d9b5fe318a
commit
5303493670
@ -118,8 +118,7 @@ static inline struct bufferevent_filtered *
|
||||
upcast(struct bufferevent *bev)
|
||||
{
|
||||
struct bufferevent_filtered *bev_f;
|
||||
if (!BEV_IS_FILTER(bev))
|
||||
return NULL;
|
||||
EVUTIL_ASSERT(BEV_IS_FILTER(bev));
|
||||
bev_f = (void*)( ((char*)bev) -
|
||||
evutil_offsetof(struct bufferevent_filtered, bev.bev));
|
||||
EVUTIL_ASSERT(BEV_IS_FILTER(&bev_f->bev.bev));
|
||||
@ -229,8 +228,6 @@ static void
|
||||
be_filter_unlink(struct bufferevent *bev)
|
||||
{
|
||||
struct bufferevent_filtered *bevf = upcast(bev);
|
||||
EVUTIL_ASSERT(bevf);
|
||||
|
||||
if (bevf->bev.options & BEV_OPT_CLOSE_ON_FREE) {
|
||||
/* Yes, there is also a decref in bufferevent_decref_.
|
||||
* That decref corresponds to the incref when we set
|
||||
@ -258,7 +255,6 @@ static void
|
||||
be_filter_destruct(struct bufferevent *bev)
|
||||
{
|
||||
struct bufferevent_filtered *bevf = upcast(bev);
|
||||
EVUTIL_ASSERT(bevf);
|
||||
if (bevf->free_context)
|
||||
bevf->free_context(bevf->context);
|
||||
|
||||
@ -575,7 +571,6 @@ be_filter_flush(struct bufferevent *bufev,
|
||||
{
|
||||
struct bufferevent_filtered *bevf = upcast(bufev);
|
||||
int processed_any = 0;
|
||||
EVUTIL_ASSERT(bevf);
|
||||
|
||||
bufferevent_incref_and_lock_(bufev);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user