From: John Tsiombikas Date: Thu, 29 Jun 2023 14:28:22 +0000 (+0300) Subject: side-stepped weird snprintf bug X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;h=5174e6b8addd6d26635d365c7d7a977aa6697140;p=retroray side-stepped weird snprintf bug --- diff --git a/libs/drawtext/draw.c b/libs/drawtext/draw.c index 08047c1..dec6101 100644 --- a/libs/drawtext/draw.c +++ b/libs/drawtext/draw.c @@ -90,24 +90,14 @@ void dtx_substring(const char *str, int start, int end) void dtx_printf(const char *fmt, ...) { va_list ap; - int buf_size; - char *buf, tmp; + static char buf[1024]; if(!dtx_font) { return; } va_start(ap, fmt); - buf_size = vsnprintf(&tmp, 0, fmt, ap); - va_end(ap); - - if(buf_size == -1) { - buf_size = 512; - } - - buf = alloca(buf_size + 1); - va_start(ap, fmt); - vsnprintf(buf, buf_size + 1, fmt, ap); + vsnprintf(buf, sizeof buf, fmt, ap); va_end(ap); dtx_string(buf);