From 2576a07e6e5a400501b126e0c73b042519bb5001 Mon Sep 17 00:00:00 2001 From: Philip Withnall <withnall@endlessm.com> Date: Thu, 20 Apr 2017 16:58:52 +0100 Subject: [PATCH] glnx-local-alloc: Make check for invalid FDs more general In general, all FDs < 0 are invalid (and should not have close() called on them), so check that. This could have caused problems if a function returned an error value < -1. Signed-off-by: Philip Withnall <withnall@endlessm.com> --- glnx-local-alloc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glnx-local-alloc.h b/glnx-local-alloc.h index f628b61c9..8c1914cf8 100644 --- a/glnx-local-alloc.h +++ b/glnx-local-alloc.h @@ -199,9 +199,9 @@ glnx_cleanup_close_fdp (int *fdp) int fd, errsv; g_assert (fdp); - + fd = *fdp; - if (fd != -1) + if (fd >= 0) { errsv = errno; (void) close (fd); -- GitLab