From c094c232eb3246154265bb035182f92fe1b17ab8 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Tue, 25 Jan 2022 15:39:38 -0700 Subject: Avoid -Wuse-after-free in tests [BZ #26779]. Reviewed-by: Carlos O'Donell --- support/tst-support-open-dev-null-range.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'support') diff --git a/support/tst-support-open-dev-null-range.c b/support/tst-support-open-dev-null-range.c index 3ed3177d57..690b9d30b7 100644 --- a/support/tst-support-open-dev-null-range.c +++ b/support/tst-support-open-dev-null-range.c @@ -39,10 +39,11 @@ check_path (int fd) char file_path[PATH_MAX]; ssize_t file_path_length = readlink (proc_fd_path, file_path, sizeof (file_path)); - free (proc_fd_path); if (file_path_length < 0) FAIL_EXIT1 ("readlink (%s, %p, %zu)", proc_fd_path, file_path, sizeof (file_path)); + + free (proc_fd_path); file_path[file_path_length] = '\0'; TEST_COMPARE_STRING (file_path, "/dev/null"); } -- cgit 1.4.1