From: Andy Green Date: Mon, 28 Feb 2011 07:45:29 +0000 (+0000) Subject: fix null protocol dereference when closing session X-Git-Tag: 1.2~153 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4302734d77585e553a66150ab60f30cbc3fd730;p=profile%2Fivi%2Flibwebsockets.git fix null protocol dereference when closing session 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 Signed-off-by: Andy Green --- diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index b3e6023..a857bea 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -187,7 +187,8 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *this, /* 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);