glibc/stdio-common
Siddhesh Poyarekar b9f72bd5de ungetc: Fix backup buffer leak on program exit [BZ #27821]
If a file descriptor is left unclosed and is cleaned up by _IO_cleanup
on exit, its backup buffer remains unfreed, registering as a leak in
valgrind.  This is not strictly an issue since (1) the program should
ideally be closing the stream once it's not in use and (2) the program
is about to exit anyway, so keeping the backup buffer around a wee bit
longer isn't a real problem.  Free it anyway to keep valgrind happy
when the streams in question are the standard ones, i.e. stdout, stdin
or stderr.

Also, the _IO_have_backup macro checks for _IO_save_base,
which is a roundabout way to check for a backup buffer instead of
directly looking for _IO_backup_base.  The roundabout check breaks when
the main get area has not been used and user pushes a char into the
backup buffer with ungetc.  Fix this to use the _IO_backup_base
directly.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 3e1d8d1d1d)
2024-08-28 16:45:25 -04:00
..
bits
Depend
Makefile ungetc: Fix backup buffer leak on program exit [BZ #27821] 2024-08-28 16:45:25 -04:00
Versions
Xprintf_buffer_done.c
Xprintf_buffer_flush.c
Xprintf_buffer_pad_1.c
Xprintf_buffer_putc_1.c
Xprintf_buffer_puts_1.c
Xprintf_buffer_write.c
Xprintf_function_invoke.c
_i18n_number.h
_itoa.c
_itowa.c
_itowa.h
asprintf.c
bug-vfprintf-nargs.c
bug1.c
bug1.input
bug2.c
bug3.c tests: replace fread by xfread 2023-06-13 19:59:08 -04:00
bug4.c tests: replace fread by xfread 2023-06-13 19:59:08 -04:00
bug5.c tests: fix warn unused result on asprintf calls 2023-06-06 08:23:53 -04:00
bug6.c
bug6.input
bug7.c
bug8.c
bug9.c
bug10.c
bug11.c
bug12.c tests: replace fread by xfread 2023-06-13 19:59:08 -04:00
bug13.c
bug14.c
bug16.c
bug17.c
bug18.c
bug18a.c
bug19.c
bug19a.c
bug20.c
bug21.c
bug22.c
bug23.c
bug24.c
bug25.c
bug26.c
bug27.c
bug28.c
bug29.c
ctermid.c
cuserid.c
dprintf.c
err_map.h
errlist-compat-data.h
errlist-data-gen.c
errlist-data.S
errlist.c
errname.c
errnobug.c
flockfile.c
fprintf.c
fscanf.c
ftrylockfile.c
funlockfile.c
fxprintf.c
gentempfd.c
getline.c
getw.c
grouping_iterator.c
grouping_iterator.h
iovfscanf.c
isoc23_fscanf.c
isoc23_scanf.c
isoc23_sscanf.c
isoc23_vfscanf.c
isoc23_vscanf.c
isoc23_vsscanf.c
isoc99_fscanf.c
isoc99_scanf.c
isoc99_sscanf.c
isoc99_vfscanf.c
isoc99_vscanf.c
isoc99_vsscanf.c
itoa-digits.c
itoa-udigits.c
itowa-digits.c
perror.c
printf-parse.h C2x printf %wN, %wfN support (bug 24466) 2023-06-19 18:52:12 +00:00
printf-parsemb.c C2x printf %wN, %wfN support (bug 24466) 2023-06-19 18:52:12 +00:00
printf-parsewc.c
printf-prs.c C2x printf %wN, %wfN support (bug 24466) 2023-06-19 18:52:12 +00:00
printf.c
printf.h
printf_buffer-char.h
printf_buffer-wchar_t.h
printf_buffer_as_file.c
printf_buffer_as_file.h
printf_buffer_done.c
printf_buffer_flush.c
printf_buffer_pad_1.c
printf_buffer_putc_1.c
printf_buffer_puts_1.c
printf_buffer_to_file.c
printf_buffer_to_file.h
printf_buffer_write.c
printf_fp.c
printf_fphex.c
printf_function_invoke.c
printf_size.c
psiginfo-data.h
psiginfo-define.h
psiginfo.c
psignal.c
putw.c
reg-modifier.c
reg-printf.c
reg-type.c
remove.c
rename.c
renameat.c
renameat2.c
scanf.c
scanf1.c
scanf2.c
scanf3.c
scanf4.c
scanf5.c
scanf7.c
scanf8.c
scanf9.c
scanf10.c
scanf11.c
scanf12.c
scanf12.input
scanf13.c
scanf14.c
scanf15.c
scanf16.c
scanf17.c
scanf18.c
scanf19.c
siglist-gen.c
siglist.S
snprintf.c
sprintf.c
sscanf.c
stdio_ext.h
tempnam.c
tempname.c
temptest.c
test-fseek.c
test-fwrite.c tests: fix warn unused result on asprintf calls 2023-06-06 08:23:53 -04:00
test-popen.c
test-strerr.c
test-vfprintf.c
test_rdwr.c tests: replace fgets by xfgets 2023-06-13 19:59:08 -04:00
tfformat.c
tiformat.c
tllformat.c
tmpfile.c
tmpfile64.c
tmpnam.c
tmpnam_r.c
translated_number_width.c
tst-bz11319-fortify2.c
tst-bz11319.c
tst-cookie.c tests: replace fread by xfread 2023-06-13 19:59:08 -04:00
tst-dprintf-length.c
tst-errno-manual.py
tst-fdopen.c
tst-ferror.c
tst-ferror.input
tst-fgets.c
tst-fileno.c
tst-fmemopen.c
tst-fmemopen2.c
tst-fmemopen3.c tests: replace fread by xfread 2023-06-13 19:59:08 -04:00
tst-fmemopen4.c
tst-fphex-wide.c
tst-fphex.c
tst-fseek.c tests: fix warn unused result on asprintf calls 2023-06-06 08:23:53 -04:00
tst-fwrite.c
tst-gets.c
tst-gets.input
tst-grouping.c
tst-grouping2.c
tst-grouping3.c
tst-grouping_iterator.c
tst-long-dbl-fphex.c
tst-memstream-string.c
tst-obprintf.c
tst-perror.c
tst-popen.c
tst-popen2.c
tst-popen3.c
tst-printf-binary-main.c
tst-printf-binary.c
tst-printf-bz18872.sh
tst-printf-bz25691.c stdio-common: tests: Incorrect maxlen parameter for swprintf 2023-06-22 00:20:55 -04:00
tst-printf-fp-free.c
tst-printf-fp-leak.c
tst-printf-intn-main.c C2x printf %wN, %wfN support (bug 24466) 2023-06-19 18:52:12 +00:00
tst-printf-intn.c C2x printf %wN, %wfN support (bug 24466) 2023-06-19 18:52:12 +00:00
tst-printf-oct.c
tst-printf-round.c
tst-printf.c
tst-printf.sh
tst-printfsz-islongdouble.c
tst-printfsz-islongdouble.sh
tst-printfsz.c
tst-put-error.c
tst-renameat2.c
tst-rndseek.c
tst-scanf-binary-c2x.c
tst-scanf-binary-c11.c
tst-scanf-binary-gnu11.c
tst-scanf-binary-gnu89.c
tst-scanf-binary-main.c C2x scanf %b support 2023-06-19 19:40:34 +00:00
tst-scanf-bz27650.c stdio-common: Add test for vfscanf with matches longer than INT_MAX [BZ #27650] 2024-08-28 16:44:35 -04:00
tst-scanf-round.c
tst-scanf-to_inpunct.c vfscanf-internal: Remove potentially unbounded allocas 2023-07-06 10:46:46 -03:00
tst-setvbuf1.c
tst-setvbuf1.expect
tst-sprintf-errno.c
tst-sprintf.c
tst-sprintf2.c
tst-sprintf3.c
tst-sscanf.c
tst-swprintf.c
tst-swscanf.c
tst-tmpnam.c
tst-unbputc.c
tst-unbputc.sh
tst-ungetc-leak.c ungetc: Fix backup buffer leak on program exit [BZ #27821] 2024-08-28 16:45:25 -04:00
tst-ungetc.c ungetc: Fix uninitialized read when putting into unused streams [BZ #27821] 2024-08-28 16:44:54 -04:00
tst-unlockedio.c
tst-vfprintf-mbs-prec.c stdio-common: tests: Incorrect maxlen parameter for swprintf 2023-06-22 00:20:55 -04:00
tst-vfprintf-user-type.c
tst-vfprintf-width-i18n.c
tst-vfprintf-width-prec-alloc.c
tst-vfprintf-width-prec.c
tst-wc-printf.c
tstdiomisc.c
tstgetln.c
tstgetln.input
tstscanf.c
tstscanf.input
vfprintf-internal.c C2x printf %wN, %wfN support (bug 24466) 2023-06-19 18:52:12 +00:00
vfprintf-process-arg.c
vfprintf.c
vfscanf-internal.c vfscanf-internal: Remove potentially unbounded allocas 2023-07-06 10:46:46 -03:00
vfscanf.c
vfwprintf-internal.c
vfwprintf.c
vfwscanf-internal.c
vfwscanf.c
vprintf.c
wprintf_buffer_as_file.c
wprintf_buffer_done.c
wprintf_buffer_flush.c
wprintf_buffer_pad_1.c
wprintf_buffer_putc_1.c
wprintf_buffer_puts_1.c
wprintf_buffer_to_file.c
wprintf_buffer_write.c
wprintf_function_invoke.c
xbug.c