From 413b3a6c551feac0b46c9dbd45da0b6e7609f0cb Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 30 Jan 2015 10:33:00 +0800 Subject: [PATCH] ssl pendding buffered reads dont dereference first time Signed-off-by: Andy Green --- lib/ssl.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/ssl.c b/lib/ssl.c index 19d7333a..f6276932 100644 --- a/lib/ssl.c +++ b/lib/ssl.c @@ -437,13 +437,16 @@ lws_ssl_capable_read(struct libwebsocket_context *context, * and if we don't realize, this data will sit there forever */ if (n == len && wsi->ssl && SSL_pending(wsi->ssl)) { - assert(!wsi->pending_read_list_next && !wsi->pending_read_list_prev); - /* add us to the linked list of guys with pending ssl */ - context->pending_read_list->pending_read_list_prev = wsi; - wsi->pending_read_list_next = context->pending_read_list; - wsi->pending_read_list_prev = NULL; - context->pending_read_list = wsi; - } + if (!wsi->pending_read_list_next && !wsi->pending_read_list_prev) { + /* add us to the linked list of guys with pending ssl */ + if (context->pending_read_list) + context->pending_read_list->pending_read_list_prev = wsi; + wsi->pending_read_list_next = context->pending_read_list; + wsi->pending_read_list_prev = NULL; + context->pending_read_list = wsi; + } + } else + lws_ssl_remove_wsi_from_buffered_list(context, wsi); return n; }