From b2c5092bf12652a0d8be9e7ca9f8c3f5431d90c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 24 May 2024 19:10:08 +0200 Subject: [PATCH] glib/tests/unix: Free fds before exiting Old valgrind wasn't spotting this but we're smarter now! --- glib/tests/unix.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/glib/tests/unix.c b/glib/tests/unix.c index c5d553aa4..c51963104 100644 --- a/glib/tests/unix.c +++ b/glib/tests/unix.c @@ -103,14 +103,18 @@ test_closefrom (void) if (flags == -1) { + int exit_code = 100 + fds[i]; async_signal_safe_message ("fd should not have been closed"); - _exit (100 + fds[i]); + g_free (fds); + _exit (exit_code); } if (flags & FD_CLOEXEC) { + int exit_code = 100 + fds[i]; async_signal_safe_message ("fd should not have been close-on-exec yet"); - _exit (100 + fds[i]); + g_free (fds); + _exit (exit_code); } } @@ -122,14 +126,18 @@ test_closefrom (void) if (flags == -1) { + int exit_code = 100 + fds[i]; async_signal_safe_message ("fd should not have been closed"); - _exit (100 + fds[i]); + g_free (fds); + _exit (exit_code); } if (!(flags & FD_CLOEXEC)) { + int exit_code = 100 + fds[i]; async_signal_safe_message ("fd should have been close-on-exec"); - _exit (100 + fds[i]); + g_free (fds); + _exit (exit_code); } } @@ -142,12 +150,14 @@ test_closefrom (void) if (flags == -1) { async_signal_safe_message ("fd should not have been closed"); + g_free (fds); _exit (100 + fd); } if (flags & FD_CLOEXEC) { async_signal_safe_message ("fd should not have been close-on-exec"); + g_free (fds); _exit (100 + fd); } } @@ -157,10 +167,12 @@ test_closefrom (void) if (fcntl (fds[i], F_GETFD) != -1 || errno != EBADF) { async_signal_safe_message ("fd should have been closed"); + g_free (fds); _exit (100 + fds[i]); } } + g_free (fds); _exit (0); }