From 173b854168aa0da0e9266494313a068f30047c66 Mon Sep 17 00:00:00 2001 From: Ross Metcalfe Date: Wed, 26 Aug 2026 18:43:03 +0100 Subject: [PATCH] Fix memory leak in rtext LoadFontFromImage method (#6100) Fix for [rtext] Memory leak at LoadFontFromImage when failing to compute spacing's --- src/rtext.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rtext.c b/src/rtext.c index 7e30cb434..a123fea31 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -438,7 +438,10 @@ Font LoadFontFromImage(Image image, Color key, int firstChar) if (!COLOR_EQUAL(pixels[y*image.width + x], key)) break; } - if ((x == 0) || (y == 0)) return font; // Security check + if ((x == 0) || (y == 0)) { + UnloadImageColors(pixels); // Unload pixel colors to prevent memory leak + return font; // Security check + } charSpacing = x; lineSpacing = y;