lws_plat_service_tsi: accessing context before checking for NULL

https://github.com/warmcat/libwebsockets/issues/730
This commit is contained in:
namowen 2016-12-24 08:02:04 +08:00 committed by Andy Green
parent f5f9196936
commit 15b35bcc63
2 changed files with 6 additions and 2 deletions

View file

@ -116,7 +116,7 @@ LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line)
LWS_VISIBLE int
lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
{
struct lws_context_per_thread *pt = &context->pt[tsi];
struct lws_context_per_thread *pt;
int n = -1, m, c;
char buf;
@ -125,6 +125,8 @@ lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
if (!context || !context->vhost_list)
return 1;
pt = &context->pt[tsi];
if (timeout_ms < 0)
goto faked_service;

View file

@ -156,7 +156,7 @@ LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line)
LWS_VISIBLE int
lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
{
struct lws_context_per_thread *pt = &context->pt[tsi];
struct lws_context_per_thread *pt;
WSANETWORKEVENTS networkevents;
struct lws_pollfd *pfd;
struct lws *wsi;
@ -168,6 +168,8 @@ lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
if (context == NULL)
return 1;
pt = &context->pt[tsi];
if (!context->service_tid_detected) {
struct lws _lws;