mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-31 13:00:49 +00:00
Ensure asprintf'd string is NUL-terminated
PUBLISHED_FROM=b4062780d22be37acdbecd86e5951245e2908ff8
This commit is contained in:
1 parent
e3a9c6afb4
commit
b535cb319a
1 file changed
+2
-2
+2
-2
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user