diff --git a/lib/core-net/wsi.c b/lib/core-net/wsi.c index ab3fee3e2..7eefe47a8 100644 --- a/lib/core-net/wsi.c +++ b/lib/core-net/wsi.c @@ -1036,6 +1036,8 @@ lws_mux_mark_immortal(struct lws *wsi) } nwsi = lws_get_network_wsi(wsi); + if (!nwsi) + return; lwsl_debug("%s: %p %p %d\n", __func__, wsi, nwsi, nwsi->immortal_substream_count); @@ -1051,6 +1053,9 @@ lws_mux_mark_immortal(struct lws *wsi) int lws_http_mark_sse(struct lws *wsi) { + if (!wsi) + return 0; + lws_http_headers_detach(wsi); lws_mux_mark_immortal(wsi); diff --git a/lib/roles/http/parsers.c b/lib/roles/http/parsers.c index 7abedb6a9..78956539c 100644 --- a/lib/roles/http/parsers.c +++ b/lib/roles/http/parsers.c @@ -1414,9 +1414,9 @@ set_parsing_complete: if (lws_hdr_total_length(wsi, WSI_TOKEN_UPGRADE)) { #if defined(LWS_ROLE_WS) - if (lws_hdr_total_length(wsi, WSI_TOKEN_VERSION)) - wsi->rx_frame_type = /* temp for ws version index */ - atoi(lws_hdr_simple_ptr(wsi, WSI_TOKEN_VERSION)); + const char *pv = lws_hdr_simple_ptr(wsi, WSI_TOKEN_VERSION); + if (pv) + wsi->rx_frame_type = atoi(pv); lwsl_parser("v%02d hdrs done\n", wsi->rx_frame_type); #endif diff --git a/lib/secure-streams/secure-streams-client.c b/lib/secure-streams/secure-streams-client.c index 57d7ca0d8..e9c849ec9 100644 --- a/lib/secure-streams/secure-streams-client.c +++ b/lib/secure-streams/secure-streams-client.c @@ -337,6 +337,8 @@ lws_sspc_create(struct lws_context *context, int tsi, const lws_ss_info_t *ssi, h = malloc(sizeof(lws_sspc_handle_t) + ssi->user_alloc + strlen(ssi->streamtype) + 1); + if (!h) + return 1; memset(h, 0, sizeof(*h)); memcpy(&h->ssi, ssi, sizeof(*ssi)); ua = (uint8_t *)&h[1];