Skip to content

Commit

Permalink
libgfortran: Fix compilation of gf_vsnprintf
Browse files Browse the repository at this point in the history
The fallback function (gf_vsnprintf) to provide a vsnprintf function
if the system library doesn't have one would not compile due to the
variable name for the string's destination buffer not being updated
after the refactor in 2018 in edaaef6.

This updates the internal logic of gf_vsnprintf to now use the str
variable defined in the function signature.

libgfortran/ChangeLog:

2024-04-04  Ian McInerney  <i.mcinerney17@imperial.ac.uk>

	* runtime/error.c (gf_vsnprintf): Fix compilation

Signed-off-by: Ian McInerney <i.mcinerney17@imperial.ac.uk>
  • Loading branch information
imciner2 authored and fxcoudert committed Apr 12, 2024
1 parent 6e7e594 commit 3bd3ca0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libgfortran/runtime/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ gf_vsnprintf (char *str, size_t size, const char *format, va_list ap)
{
int written;

written = vsprintf(buffer, format, ap);
written = vsprintf(str, format, ap);

if (written >= size - 1)
{
/* The error message was longer than our buffer. Ouch. Because
/* The error message was longer than the string size. Ouch. Because
we may have messed up things badly, report the error and
quit. */
#define ERROR_MESSAGE "Internal error: buffer overrun in gf_vsnprintf()\n"
write (STDERR_FILENO, buffer, size - 1);
#define ERROR_MESSAGE "Internal error: string overrun in gf_vsnprintf()\n"
write (STDERR_FILENO, str, size - 1);
write (STDERR_FILENO, ERROR_MESSAGE, strlen (ERROR_MESSAGE));
sys_abort ();
#undef ERROR_MESSAGE
Expand Down

0 comments on commit 3bd3ca0

Please sign in to comment.