From 249b2d049b5718847c53b76ac807fe2500d75b1d Mon Sep 17 00:00:00 2001
From: Andy Green <andy@warmcat.com>
Date: Wed, 4 Jan 2017 14:38:39 +0800
Subject: [PATCH] client: protect against possible NULL deref path

---
 lib/libwebsockets.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index 5ab49a12..dc4aa5f4 100755
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -408,7 +408,9 @@ just_kill_connection:
 		char* errorString;
 
 		lwsl_debug("Connection closed before server reply\n");
-		errorString = lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP);
+		errorString = NULL;
+		if (wsi->u.hdr.ah)
+			errorString = lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP);
 		if (errorString) {
 			context->protocols[0].callback(wsi,
 					LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
-- 
GitLab