Skip to content

Commit fbf9dda

Browse files
compnerdlorentey
authored andcommitted
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. (cherry picked from commit 37ee73c)
1 parent 3aa05d7 commit fbf9dda

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

stdlib/public/runtime/ReflectionMirror.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ int asprintf(char **strp, const char *fmt, ...) {
5757
return -1;
5858

5959
length = _vsnprintf(*strp, length, fmt, argp1);
60+
(*strp)[length] = '\0';
6061

6162
va_end(argp0);
6263
va_end(argp1);

0 commit comments

Comments
 (0)