Fix crash in c_vsnprintf

PUBLISHED_FROM=020d1b9ea66862f71b08232b827cdd6e97528765
This commit is contained in:
Alexander Alashkin authored and rojer committed 2016-02-13 13:59:15 +00:00
1 parent 96c023df41
commit 148e1926e8
1 file changed
+6 -3
+6 -3
View File
@@ -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 */