From cd25d98bfa38c87bd857264e876cd8be42eb3678 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 27 Jun 2017 14:22:28 +0200 Subject: Avoid calling close(-1) While this is perfectly OK on Unix, it causes annoying valgrind warnings, and might be otherwise confusing to others. On Windows, the runtime can actually abort the process if this is called. push.c part taken from a patch by Pedro Pombeiro. --- stream/stream.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'stream') diff --git a/stream/stream.c b/stream/stream.c index d4dea4486f..ca17fa787f 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -885,8 +885,10 @@ struct mp_cancel { static void cancel_destroy(void *p) { struct mp_cancel *c = p; - close(c->wakeup_pipe[0]); - close(c->wakeup_pipe[1]); + if (c->wakeup_pipe[0] >= 0) { + close(c->wakeup_pipe[0]); + close(c->wakeup_pipe[1]); + } } struct mp_cancel *mp_cancel_new(void *talloc_ctx) -- cgit v1.2.3