equal
deleted
inserted
replaced
2581 |
2581 |
2582 ATTRIBUTE_PRINTF(3, 0) |
2582 ATTRIBUTE_PRINTF(3, 0) |
2583 int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) { |
2583 int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) { |
2584 // see bug 4399518, 4417214 |
2584 // see bug 4399518, 4417214 |
2585 if ((intptr_t)count <= 0) return -1; |
2585 if ((intptr_t)count <= 0) return -1; |
2586 return vsnprintf(str, count, fmt, args); |
2586 |
|
2587 int result = vsnprintf(str, count, fmt, args); |
|
2588 if ((result > 0 && (size_t)result >= count) || result == -1) { |
|
2589 str[count - 1] = '\0'; |
|
2590 result = -1; |
|
2591 } |
|
2592 |
|
2593 return result; |
2587 } |
2594 } |
2588 |
2595 |
2589 ATTRIBUTE_PRINTF(3, 0) |
2596 ATTRIBUTE_PRINTF(3, 0) |
2590 int jio_snprintf(char *str, size_t count, const char *fmt, ...) { |
2597 int jio_snprintf(char *str, size_t count, const char *fmt, ...) { |
2591 va_list args; |
2598 va_list args; |