diff mbox series

stdio-common: Fix memory leak in tst-freopen4* tests on UNSUPPORTED

Message ID 871q16alim.fsf@oldenburg.str.redhat.com
State New
Headers show
Series stdio-common: Fix memory leak in tst-freopen4* tests on UNSUPPORTED | expand

Commit Message

Florian Weimer Sept. 26, 2024, 8:04 a.m. UTC
The temp_dir allocation leaks if support_can_chroot returns false.

---
 stdio-common/tst-freopen4-main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)


base-commit: cc84cd389c7329ceb38228f931044e8c84ca7245
diff mbox series

Patch

diff --git a/stdio-common/tst-freopen4-main.c b/stdio-common/tst-freopen4-main.c
index e169442cf4..7284677a97 100644
--- a/stdio-common/tst-freopen4-main.c
+++ b/stdio-common/tst-freopen4-main.c
@@ -33,7 +33,7 @@  int
 do_test (void)
 {
   mtrace ();
-  char *temp_dir = support_create_temp_directory ("tst-freopen4");
+  char *temp_dir;
   FILE *fp;
   int ret;
 
@@ -45,6 +45,8 @@  do_test (void)
   support_become_root ();
   if (!support_can_chroot ())
     return EXIT_UNSUPPORTED;
+
+  temp_dir = support_create_temp_directory ("tst-freopen4");
   xchroot (temp_dir);
 
   /* Test freopen with NULL, renamed file.  This verifies that