mirror of
https://github.com/cesanta/mongoose.git
synced 2025-08-06 13:37:34 +08:00
Ensure asprintf'd string is NUL-terminated
PUBLISHED_FROM=b4062780d22be37acdbecd86e5951245e2908ff8
This commit is contained in:
parent
e3a9c6afb4
commit
b535cb319a
@ -10238,13 +10238,13 @@ int asprintf(char **strp, const char *fmt, ...) {
|
||||
va_end(ap);
|
||||
|
||||
if (len > 0) {
|
||||
*strp = realloc(*strp, len);
|
||||
*strp = realloc(*strp, len + 1);
|
||||
if (*strp == NULL) return -1;
|
||||
}
|
||||
|
||||
if (len >= BUFSIZ) {
|
||||
va_start(ap, fmt);
|
||||
len = vsnprintf(*strp, len, fmt, ap);
|
||||
len = vsnprintf(*strp, len + 1, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user