glibc/stdio-common
Siddhesh Poyarekar 3e1d8d1d1d 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>
2024-08-15 13:56:13 -04:00
..
bits
_i18n_number.h
_itoa.c
_itowa.c
_itowa.h
asprintf.c
bug1.c
bug1.input
bug2.c
bug3.c
bug4.c
bug5.c
bug6.c
bug6.input
bug7.c
bug8.c
bug9.c
bug10.c
bug11.c
bug12.c
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
bug-vfprintf-nargs.c
ctermid.c
cuserid.c
Depend
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
Makefile ungetc: Fix backup buffer leak on program exit [BZ #27821] 2024-08-15 13:56:13 -04:00
perror.c
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_buffer-char.h
printf_buffer-wchar_t.h
printf_fp.c
printf_fphex.c
printf_function_invoke.c
printf_size.c
printf-parse.h
printf-parsemb.c
printf-parsewc.c
printf-prs.c
printf.c
printf.h
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
renameat2.c
renameat.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
scanf.c
siglist-gen.c
siglist.S
snprintf.c
sprintf.c
sscanf.c
stdio_ext.h
tempnam.c
tempname.c
temptest.c
test_rdwr.c
test-fseek.c
test-fwrite.c
test-popen.c
test-strerr.c
test-vfprintf.c
tfformat.c
tiformat.c
tllformat.c
tmpdir.c
tmpdir.h
tmpfile64.c
tmpfile.c
tmpnam_r.c
tmpnam.c
translated_number_width.c
tst-bz11319-fortify2.c
tst-bz11319.c
tst-cookie.c
tst-dprintf-length.c
tst-errno-manual.py
tst-fdopen.c
tst-ferror.c
tst-ferror.input
tst-fgets.c
tst-fileno.c
tst-fmemopen2.c
tst-fmemopen3.c
tst-fmemopen4.c
tst-fmemopen.c
tst-fphex-wide.c
tst-fphex.c
tst-fseek.c
tst-fwrite.c
tst-gets.c
tst-gets.input
tst-grouping2.c
tst-grouping3.c
tst-grouping_iterator.c
tst-grouping.c
tst-long-dbl-fphex.c
tst-memstream-string.c
tst-obprintf.c
tst-perror.c
tst-popen2.c
tst-popen3.c
tst-popen.c
tst-printf-binary-main.c
tst-printf-binary.c
tst-printf-bz18872.sh
tst-printf-bz25691.c
tst-printf-fp-free.c
tst-printf-fp-leak.c
tst-printf-intn-main.c
tst-printf-intn.c
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-c11.c
tst-scanf-binary-c23.c
tst-scanf-binary-gnu11.c
tst-scanf-binary-gnu89.c
tst-scanf-binary-main.c
tst-scanf-bz27650.c
tst-scanf-intn-main.c
tst-scanf-intn.c
tst-scanf-round.c
tst-scanf-to_inpunct.c
tst-setvbuf1.c
tst-setvbuf1.expect
tst-sprintf2.c
tst-sprintf3.c
tst-sprintf-errno.c
tst-sprintf.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-15 13:56:13 -04:00
tst-ungetc.c ungetc: Fix uninitialized read when putting into unused streams [BZ #27821] 2024-08-15 13:55:07 -04:00
tst-unlockedio.c
tst-vfprintf-mbs-prec.c
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
Versions
vfprintf-internal.c
vfprintf-process-arg.c
vfprintf.c
vfscanf-internal.c
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
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