File libcdio-0.94-leak-02.patch of Package libcdio.24379
From 039ba3dca11c391dfca1e29e7975e598c3c5a202 Mon Sep 17 00:00:00 2001
From: "R. Bernstein" <rocky@gnu.org>
Date: Sun, 19 Nov 2017 23:08:58 -0500
Subject: [PATCH 2/20] Remove memory leaks in realpath test
---
test/driver/realpath.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/test/driver/realpath.c b/test/driver/realpath.c
index 974c281d..394413be 100644
--- a/test/driver/realpath.c
+++ b/test/driver/realpath.c
@@ -103,18 +103,21 @@ main(int argc, const char *argv[])
psz_tmp_subdir = get_temporary_name(NULL, "temporary directory");
if (NULL == psz_tmp_subdir) {
+ free(psz_tmp_subdir);
exit(77);
}
-
if (-1 == check_rc(_mkdir(psz_tmp_subdir),
- "mkdir", psz_tmp_subdir))
+ "mkdir", psz_tmp_subdir)) {
+ free(psz_tmp_subdir);
exit(77);
+ }
cdio_realpath(psz_tmp_subdir, tmp_subdir);
if (0 == strlen(tmp_subdir)) {
fprintf(stderr, "cdio_realpath on temp directory %s failed\n",
psz_tmp_subdir);
+ free(psz_tmp_subdir);
exit(1);
}
@@ -150,6 +153,7 @@ main(int argc, const char *argv[])
if (0 != strncmp(psz_file_check, orig_file, PATH_MAX)) {
fprintf(stderr, "simple cdio_realpath failed: %s vs %s\n",
psz_file_check, orig_file);
+ free(psz_symlink_file);
exit(3);
}
check_rc(unlink(psz_symlink_file), "unlink", psz_symlink_file);
@@ -164,6 +168,7 @@ main(int argc, const char *argv[])
if (0 != strncmp(psz_file_check, symlink_file, PATH_MAX)) {
fprintf(stderr, "direct cdio_realpath cycle test failed. %s vs %s\n",
psz_file_check, symlink_file);
+ free(psz_symlink_file);
exit(4);
}
check_rc(unlink(psz_symlink_file), "unlink", psz_symlink_file);
@@ -173,6 +178,9 @@ main(int argc, const char *argv[])
check_rc(unlink(psz_orig_file), "unlink", psz_orig_file);
check_rc(rmdir(psz_tmp_subdir), "rmdir", psz_tmp_subdir);
+ free(psz_symlink_file);
+ free(psz_tmp_subdir);
+ free(psz_orig_file);
return 0;
}
--
2.17.0