Commit b535cb31 authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

Ensure asprintf'd string is NUL-terminated

PUBLISHED_FROM=b4062780d22be37acdbecd86e5951245e2908ff8
parent e3a9c6af
...@@ -10238,13 +10238,13 @@ int asprintf(char **strp, const char *fmt, ...) { ...@@ -10238,13 +10238,13 @@ int asprintf(char **strp, const char *fmt, ...) {
va_end(ap); va_end(ap);
if (len > 0) { if (len > 0) {
*strp = realloc(*strp, len); *strp = realloc(*strp, len + 1);
if (*strp == NULL) return -1; if (*strp == NULL) return -1;
} }
if (len >= BUFSIZ) { if (len >= BUFSIZ) {
va_start(ap, fmt); va_start(ap, fmt);
len = vsnprintf(*strp, len, fmt, ap); len = vsnprintf(*strp, len + 1, fmt, ap);
va_end(ap); va_end(ap);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment