diff --git a/ubb-la/gui.c b/ubb-la/gui.c index b17c3d8..fb15c20 100644 --- a/ubb-la/gui.c +++ b/ubb-la/gui.c @@ -122,17 +122,18 @@ static void update(void) static void textf(int x, int y, uint32_t color, const char *fmt, ...) { va_list ap; - char *s; + char *tmp, *s; uint8_t *p; int ix, iy; - int res; va_start(ap, fmt); - res = vasprintf(&s, fmt, ap); + if (vasprintf(&tmp, fmt, ap) < 0) { + perror("vasprintf"); + exit(1); + } va_end(ap); - (void) res; - while (*s) { + for (s = tmp; *s; s++) { p = gfxPrimitivesFontdata+(*s << 3); for (iy = 0; iy != 8; iy++) { for (ix = 0; ix != 8; ix++) @@ -141,8 +142,8 @@ static void textf(int x, int y, uint32_t color, const char *fmt, ...) p++; } x += 8; - s++; } + free(tmp); }