diff mbox series

asprintf: set result ptr to NULL on error

Message ID 20230119034258.15881-1-kilobyte@angband.pl
State New
Headers show
Series asprintf: set result ptr to NULL on error | expand

Commit Message

Adam Borowski Jan. 19, 2023, 3:42 a.m. UTC
This is what other implementations do, and it's too easy to assume this
is being done.  Thus, let's avoid a footgun.

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
 libio/vasprintf.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series


diff --git a/libio/vasprintf.c b/libio/vasprintf.c
index facc224295..d56a839fe1 100644
--- a/libio/vasprintf.c
+++ b/libio/vasprintf.c
@@ -95,6 +95,7 @@  int
 __vasprintf_internal (char **result_ptr, const char *format, va_list args,
 		      unsigned int mode_flags)
+  *result_ptr = NULL;
   struct __printf_buffer_asprintf buf;
   __printf_buffer_init (&buf.base, buf.direct, array_length (buf.direct),