mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user