glibc/glibc-RHEL-115823-8.patch
Frédéric Bérat 0cdd6d71bb Fix memory leak in freopen and improve testing
RPM-Changelog:
 - Fix memory leak in freopen, mode flag and wide-oriented stream handling (RHEL-115823)
 - Add comprehensive tests and document limitations (RHEL-115823)
Resolves: RHEL-115823
2025-10-30 13:36:52 +00:00

31 lines
931 B
Diff

commit 6948ee4edf0c57c556f8d5f394d9191216d05780
Author: Florian Weimer <fweimer@redhat.com>
Date: Sat Sep 28 21:06:11 2024 +0200
stdio-common: Fix memory leak in tst-freopen4* tests on UNSUPPORTED
The temp_dir allocation leaks if support_can_chroot returns false.
diff --git a/stdio-common/tst-freopen4-main.c b/stdio-common/tst-freopen4-main.c
index e169442cf4df2e9d..7284677a97e10af6 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