aboutsummaryrefslogtreecommitdiff
path: root/dc/dc.c
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-05-11 21:25:53 -0400
committeriamcheeseman <[email protected]>2026-05-11 21:25:53 -0400
commitc1dd3ce9850fb2906aa5937b4374d1c0fc74ccf7 (patch)
tree280796b30fe69df1f5ca83a016e3845c3c2f51b1 /dc/dc.c
parent06cdc35c5a993440a0b61f6e29f6ccbf4ff608ff (diff)
fix a double free
Diffstat (limited to 'dc/dc.c')
-rw-r--r--dc/dc.c12
1 files 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;