asprintf: set result ptr to NULL on error

Message ID
State New
Series asprintf: set result ptr to NULL on error |


Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

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 <>
 libio/vasprintf.c | 1 +
 1 file changed, 1 insertion(+)


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,, array_length (,