=cut
*/
void i_push_error(int code, char const *msg) {
- int size = strlen(msg)+1;
+ size_t size = strlen(msg)+1;
if (error_sp <= 0)
/* bad, bad programmer */
*/
void i_push_errorvf(int code, char const *fmt, va_list ap) {
char buf[1024];
-#if defined(_MSC_VER)
+#if defined(IMAGER_VSNPRINTF)
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+#elif defined(_MSC_VER)
_vsnprintf(buf, sizeof(buf), fmt, ap);
#else
/* is there a way to detect vsnprintf()?
failed_cb(error_stack + error_sp);
if (failures_fatal) {
int sp;
- int total; /* total length of error messages */
+ size_t total; /* total length of error messages */
char *full; /* full message for logging */
if (argv0)
fprintf(stderr, "%s: ", argv0);
i_fatal() */
total = 1; /* remember the NUL */
for (sp = error_sp; error_stack[sp].msg; ++sp) {
- total += strlen(error_stack[sp].msg) + 2;
+ size_t new_total += strlen(error_stack[sp].msg) + 2;
+ if (new_total < total) {
+ /* overflow, somehow */
+ break;
+ }
}
full = mymalloc(total);
if (!full) {