Skip to content

Commit 37ee73c

Browse files
committed
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.
1 parent 103961a commit 37ee73c

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
@@ -56,6 +56,7 @@ int asprintf(char **strp, const char *fmt, ...) {
5656
return -1;
5757

5858
length = _vsnprintf(*strp, length, fmt, argp1);
59+
(*strp)[length] = '\0';
5960

6061
va_end(argp0);
6162
va_end(argp1);

0 commit comments

Comments
 (0)