From 602fb83512e9e42e3dd72d68c1dd99ef97356ee9 Mon Sep 17 00:00:00 2001 From: zeljan1 Date: Sat, 28 Dec 2024 20:42:52 +0100 Subject: [PATCH] FreeType: fixed code mess and memory leak in ttcache. Patch by lagprogramming. issue #40202 --- components/freetype/ttcache.pas | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/freetype/ttcache.pas b/components/freetype/ttcache.pas index f6a4e78549..417f86d1ef 100644 --- a/components/freetype/ttcache.pas +++ b/components/freetype/ttcache.pas @@ -298,7 +298,7 @@ var label Fail; begin - Result := False; + //Result := False; (* LOCK *) current := cache.idle; if current <> nil then @@ -312,7 +312,9 @@ var begin (* if no object was found in the cache, create a new one *) obj:=nil; - if Alloc( obj, cache.clazz^.object_size ) then exit; + + if Alloc( obj, cache.clazz^.object_size ) then + goto Fail; current := Element_New; if current = nil then goto Fail; @@ -320,7 +322,11 @@ var current^.data := obj; error := cache.clazz^.init( obj, parent_data ); - if error then goto Fail; + if error then + begin + Element_Done( current ); + goto Fail; + end; end; (* LOCK *)