diff --git a/lib/core/context.c b/lib/core/context.c index f4887b9a9..38aaf3b53 100644 --- a/lib/core/context.c +++ b/lib/core/context.c @@ -490,10 +490,7 @@ lwsl_info("context created\n"); #if defined(LWS_WITH_PEER_LIMITS) lws_free_set_NULL(context->pl_hash_table); #endif - lws_free_set_NULL(context->pt[0].fds); - lws_plat_context_late_destroy(context); - lws_free_set_NULL(context); - return NULL; + goto fail_clean_pipes; } lws_context_init_extensions(info, context); @@ -538,6 +535,18 @@ lwsl_info("context created\n"); return context; +#if defined(LWS_WITH_NETWORK) +fail_clean_pipes: + for (n = 0; n < context->count_threads; n++) + lws_destroy_event_pipe(context->pt[n].pipe_wsi); + + lws_free_set_NULL(context->pt[0].fds); + lws_plat_context_late_destroy(context); + lws_free_set_NULL(context); + + return NULL; +#endif + bail: lws_context_destroy(context);