From aeae54072c5393595f4555d2d60acd384ffc955f Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Wed, 3 Sep 2025 21:33:38 -0600 Subject: [PATCH] fix(font/freetype): mark glyph bitmap as owned if modifying This caused a malloc fault due to a double free when deiniting the face if we didn't do this, which makes sense- making it possible to actually load bitmap fonts revealed this bug which was sitting dormant the whole time before that ever since I refactored the freetype rasterization. --- src/font/face/freetype.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/font/face/freetype.zig b/src/font/face/freetype.zig index ef4275131..19eef2dac 100644 --- a/src/font/face/freetype.zig +++ b/src/font/face/freetype.zig @@ -594,6 +594,12 @@ pub const Face = struct { freetype.c.FT_PIXEL_MODE_GRAY, => {}, else => { + // Make sure the slot owns its bitmap, + // since we'll be modifying it here. + if (freetype.c.FT_GlyphSlot_Own_Bitmap(glyph) != 0) { + return error.BitmapHandlingError; + } + var converted: freetype.c.FT_Bitmap = undefined; freetype.c.FT_Bitmap_Init(&converted); if (freetype.c.FT_Bitmap_Convert(