From e96b2c680a262f2345f1bbd2318edc60397c6390 Mon Sep 17 00:00:00 2001
From: Andy Green <andy.green@linaro.org>
Date: Sun, 6 Dec 2015 11:04:05 +0800
Subject: [PATCH] coverity 155649 medium possible write to null pointer

Signed-off-by: Andy Green <andy.green@linaro.org>
---
 lib/libwebsockets.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index 671299dc2..a365cbc25 100644
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -718,8 +718,10 @@ lws_set_proxy(struct lws_context *context, const char *proxy)
 
 		return -1;
 	} else {
-		*p = '\0';
-		context->http_proxy_port = atoi(p + 1);
+		if (p) {
+			*p = '\0';
+			context->http_proxy_port = atoi(p + 1);
+		}
 	}
 
 	lwsl_notice(" Proxy %s:%u\n", context->http_proxy_address,