From 37ee73cda9c99cf069f6de7a9ef1b850e204c9c7 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Tue, 14 Jul 2020 20:01:12 -0700 Subject: [PATCH] runtime: correct the `asprintf` shim for Windows Ensure that the string that is formed from the `asprintf` call is null-terminated. The `_vsnprintf` call will not null-terminate the string if the length is not sufficient. --- stdlib/public/runtime/ReflectionMirror.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/public/runtime/ReflectionMirror.mm b/stdlib/public/runtime/ReflectionMirror.mm index 74a644912e1..b24737360dc 100644 --- a/stdlib/public/runtime/ReflectionMirror.mm +++ b/stdlib/public/runtime/ReflectionMirror.mm @@ -56,6 +56,7 @@ int asprintf(char **strp, const char *fmt, ...) { return -1; length = _vsnprintf(*strp, length, fmt, argp1); + (*strp)[length] = '\0'; va_end(argp0); va_end(argp1);