From 33a1e905113f05c3c1eec3b75e0727ca81a551b1 Mon Sep 17 00:00:00 2001
From: Diana Ren <diren@microsoft.com>
Date: Tue, 2 Apr 2019 16:49:14 -0700
Subject: [PATCH] client: opesssl: also check wsi for NULL on non-error path

same change as a58b389 in other code path - check wsi before
 accessing and return 0 (not ok) if null
---
 lib/client/ssl-client.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/client/ssl-client.c b/lib/client/ssl-client.c
index cad1d9aa..1d40c504 100644
--- a/lib/client/ssl-client.c
+++ b/lib/client/ssl-client.c
@@ -77,6 +77,10 @@ OpenSSL_client_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
 
 	ssl = X509_STORE_CTX_get_ex_data(x509_ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
 	wsi = SSL_get_ex_data(ssl, openssl_websocket_private_data_index);
+	if (!wsi) {
+		lwsl_err("can't retrieve wsi from ssl private data");
+		return 0;
+	}
 
 	n = lws_get_context_protocol(wsi->context, 0).callback(wsi,
 			LWS_CALLBACK_OPENSSL_PERFORM_SERVER_CERT_VERIFICATION,
-- 
GitLab