Commit 148e1926 authored by Alexander Alashkin's avatar Alexander Alashkin Committed by rojer

Fix crash in c_vsnprintf

    PUBLISHED_FROM=020d1b9ea66862f71b08232b827cdd6e97528765
parent 96c023df
...@@ -1773,9 +1773,12 @@ int c_vsnprintf(char *buf, size_t buf_size, const char *fmt, va_list ap) { ...@@ -1773,9 +1773,12 @@ int c_vsnprintf(char *buf, size_t buf_size, const char *fmt, va_list ap) {
C_SNPRINTF_APPEND_CHAR(' '); C_SNPRINTF_APPEND_CHAR(' ');
} }
/* Ignore negative and 0 precisions */ /* `s` may be NULL in case of %.*s */
for (j = 0; (precision <= 0 || j < precision) && s[j] != '\0'; j++) { if (s != NULL) {
C_SNPRINTF_APPEND_CHAR(s[j]); /* 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') { } else if (ch == 'c') {
ch = va_arg(ap, int); /* Always fetch parameter */ ch = va_arg(ap, int); /* Always fetch parameter */
......
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