mirror of
https://github.com/cesanta/mongoose.git
synced 2025-01-21 09:23:10 +08:00
Fix crash in c_vsnprintf
PUBLISHED_FROM=020d1b9ea66862f71b08232b827cdd6e97528765
This commit is contained in:
parent
96c023df41
commit
148e1926e8
@ -1773,9 +1773,12 @@ int c_vsnprintf(char *buf, size_t buf_size, const char *fmt, va_list ap) {
|
||||
C_SNPRINTF_APPEND_CHAR(' ');
|
||||
}
|
||||
|
||||
/* Ignore negative and 0 precisions */
|
||||
for (j = 0; (precision <= 0 || j < precision) && s[j] != '\0'; j++) {
|
||||
C_SNPRINTF_APPEND_CHAR(s[j]);
|
||||
/* `s` may be NULL in case of %.*s */
|
||||
if (s != NULL) {
|
||||
/* Ignore negative and 0 precisions */
|
||||
for (j = 0; (precision <= 0 || j < precision) && s[j] != '\0'; j++) {
|
||||
C_SNPRINTF_APPEND_CHAR(s[j]);
|
||||
}
|
||||
}
|
||||
} else if (ch == 'c') {
|
||||
ch = va_arg(ap, int); /* Always fetch parameter */
|
||||
|
Loading…
Reference in New Issue
Block a user