]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Do not call fputc from _bfd_doprnt
authorTom Tromey <tom@tromey.com>
Mon, 12 Feb 2024 21:25:03 +0000 (14:25 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 12 Feb 2024 23:25:37 +0000 (16:25 -0700)
I noticed that _bfd_doprnt can unconditionally call fputc.  However,
when called from error_handler_sprintf, this will likely result in a
crash, as the stream argument does not actually point to a FILE.

* bfd.c (_bfd_doprnt): Do not call fputc.

bfd/bfd.c

index 0776145af52cfb2f30a43c90eb421f8c77a49750..6c60227f1dc415cc4c6695b038c0cbbd0b3aeed1 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1027,7 +1027,7 @@ _bfd_doprnt (print_func print, void *stream, const char *format,
        }
       else if (ptr[1] == '%')
        {
-         fputc ('%', stream);
+         print (stream, "%%");
          result = 1;
          ptr += 2;
        }