Thanks to Christopher Baker for pointing out that when we close a session,
if the close is coming before a protocol was negotiated for the connection
or when the protocol was otherwise left at NULL, we'll blow a segfault.
This implements his proposed fix.
Reported-by: Christopher Baker <me@christopherbaker.net>
Signed-off-by: Andy Green <andy@warmcat.com>
/* tell the user it's all over for this guy */
- if (wsi->protocol->callback && old_state == WSI_STATE_ESTABLISHED)
+ if (wsi->protocol && wsi->protocol->callback &&
+ old_state == WSI_STATE_ESTABLISHED)
wsi->protocol->callback(this, wsi, LWS_CALLBACK_CLOSED,
wsi->user_space, NULL, 0);