From 27966c29e12903b18d9ac4fd9646346e13b239b2 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Mon, 15 Feb 2016 21:00:39 +0800 Subject: [PATCH] coverity 158145 lws_header_table_detatch must handle no ah attached callers should protect it so this doesn't make a problem. But Coverity is correct the code is confused about it. Make it okay if we close a connection before the ah got attached. Signed-off-by: Andy Green --- lib/parsers.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/parsers.c b/lib/parsers.c index 55c5dacc..3c49bec3 100644 --- a/lib/parsers.c +++ b/lib/parsers.c @@ -179,10 +179,8 @@ int lws_header_table_detach(struct lws *wsi) (void *)wsi, (void *)wsi->u.hdr.ah, wsi->tsi, pt->ah_count_in_use); - assert(ah); - /* may not be detached while he still has unprocessed rx */ - if (ah->rxpos != ah->rxlen) { + if (ah && ah->rxpos != ah->rxlen) { lwsl_err("%s: %p: rxpos:%d, rxlen:%d\n", __func__, wsi, ah->rxpos, ah->rxlen); assert(ah->rxpos == ah->rxlen); @@ -191,7 +189,7 @@ int lws_header_table_detach(struct lws *wsi) lws_pt_lock(pt); pwsi = &pt->ah_wait_list; - if (!wsi->u.hdr.ah) { /* remove from wait list if that's all */ + if (!ah) { /* remove from wait list if that's all */ if (wsi->socket_is_permanently_unusable) while (*pwsi) { if (*pwsi == wsi) {