aboutsummaryrefslogtreecommitdiffstats
path: root/support/tst-support-open-dev-null-range.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2022-01-25 15:39:38 -0700
committerMartin Sebor <msebor@redhat.com>2022-01-26 10:38:23 -0700
commitc094c232eb3246154265bb035182f92fe1b17ab8 (patch)
tree4b5d30d81c1870bbda23f9d079be4509fd4d2843 /support/tst-support-open-dev-null-range.c
parentelf: Replace tst-p_alignmod1-editX with a python script (diff)
downloadglibc-c094c232eb3246154265bb035182f92fe1b17ab8.tar.xz
glibc-c094c232eb3246154265bb035182f92fe1b17ab8.zip
Avoid -Wuse-after-free in tests [BZ #26779].
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'support/tst-support-open-dev-null-range.c')
-rw-r--r--support/tst-support-open-dev-null-range.c3
1 files changed, 2 insertions, 1 deletions
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");
}