From 7b5a070efc883536eccface318ecdcd83580a354 Mon Sep 17 00:00:00 2001 From: Earl Robsham Date: Wed, 19 Oct 2022 17:11:59 -0400 Subject: [PATCH] pt_destroy: possible leaking pipe side Updates the `lws_pt_destroy()` logic to ensure the pipe fds are closed if either `pt->dummy_pipe_fds[0]` or `pt->dummy_pipe_fds[1]` are still valid (previously was only checking `pt->dummy_pipe_fds[0]` which was resulting in the write fd to leak whenever a context was destroyed). --- lib/core/context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/context.c b/lib/core/context.c index c1132d975..b9b724edf 100644 --- a/lib/core/context.c +++ b/lib/core/context.c @@ -1688,9 +1688,9 @@ lws_pt_destroy(struct lws_context_per_thread *pt) pt->pipe_wsi = NULL; } - if (pt->dummy_pipe_fds[0] + if ((pt->dummy_pipe_fds[0] || pt->dummy_pipe_fds[1]) #if !defined(WIN32) - && (int)pt->dummy_pipe_fds[0] != -1 + && ((int)pt->dummy_pipe_fds[0] != -1 || (int)pt->dummy_pipe_fds[1] != -1) #endif ) { struct lws wsi;