From c1dd3ce9850fb2906aa5937b4374d1c0fc74ccf7 Mon Sep 17 00:00:00 2001 From: iamcheeseman Date: Mon, 11 May 2026 21:25:53 -0400 Subject: fix a double free --- dc/dc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dc/dc.c b/dc/dc.c index b68988e..99f9cf1 100644 --- a/dc/dc.c +++ b/dc/dc.c @@ -13,7 +13,7 @@ #define TILE_SIZE 16 struct ty_image img; -struct ty_font font; +struct ty_font font = {}; double last_frame = 0; @@ -182,8 +182,14 @@ int main(void) ty_free_image(img); ty_free_image(font_img); - for (int i = 0; i < CHAR_MAX; i++) - ty_free_image(font.glyphs[i]); + for (int i = 0; i < CHAR_MAX; i++) { + if (i >= 'a' && i <= 'z') + continue; + struct ty_image glyph = font.glyphs[i]; + if (glyph.width * glyph.height == 0) + continue; + ty_free_image(glyph); + } ty_deinit(); return 0; -- cgit v1.3-2-g0d8e