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 <andy.green@linaro.org>
This commit is contained in:
Andy Green 2016-02-15 21:00:39 +08:00
parent 1e32c2b67a
commit 27966c29e1

View file

@ -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) {