From 3584c1d8bcb9d5f4e2acddd8e98bf1d32a0b49b1 Mon Sep 17 00:00:00 2001 From: dmitry Date: Fri, 16 Apr 2010 08:59:46 +0000 Subject: [PATCH] carbon: fix for possible mem corruption on ExtTextDraw git-svn-id: trunk@24649 - --- lcl/interfaces/carbon/carbongdiobjects.pp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lcl/interfaces/carbon/carbongdiobjects.pp b/lcl/interfaces/carbon/carbongdiobjects.pp index 6afefa687b..f2e41331bc 100644 --- a/lcl/interfaces/carbon/carbongdiobjects.pp +++ b/lcl/interfaces/carbon/carbongdiobjects.pp @@ -1005,6 +1005,7 @@ var Layouts : PATSLayoutRecordArray; LayCount : ItemCount; begin + if not Assigned(FDX) or (FDXCount=0) then Exit; { if idx < FDXCount then begin} Layouts:=nil; @@ -1016,7 +1017,7 @@ begin if Assigned(Layouts) and (Laycount>0) then begin ofs:=0; - for i:=0 to Min(FDXCount, Min(LayCount, Count)) do + for i:=0 to Min(FDXCount, Min(LayCount, Count))-1 do begin Deltas^[i] := Layouts^[i].realPos-Long2Fix(ofs); Layouts^[i].realPos:=Long2Fix(ofs); @@ -1062,6 +1063,9 @@ begin theValue := @OverSpec; ATSUSetTextLayoutRefCon(FLayout, UInt32(Self)); ATSUSetLayoutControls (FLayout, 1, @theTag, @theSize, @theValue); + end else begin + FDX:=nil; + FDXCount:=0; end; if OSError(ATSUDrawText(FLayout, kATSUFromTextBeginning, kATSUToTextEnd,