From 06530a1991f7274a1335c410246703141135762b Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Thu, 8 Sep 2011 07:41:21 +0000 Subject: [PATCH] thtmlport: Fixes a crash git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1922 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/thtmlport/package/htmlmisc.pas | 8 ++++++-- components/thtmlport/package/htmlun2.pas | 9 ++++----- components/thtmlport/package/styleun.pas | 3 +-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/components/thtmlport/package/htmlmisc.pas b/components/thtmlport/package/htmlmisc.pas index 892f48c4a..f239a9d2c 100755 --- a/components/thtmlport/package/htmlmisc.pas +++ b/components/thtmlport/package/htmlmisc.pas @@ -651,10 +651,14 @@ begin if cchMultiByte < 0 then {Null terminated?} s := lpMultiByteStr else + begin + if lpMultiByteStr = nil then s := '' + else begin - SetLength(s, cchMultiByte); - Move(lpMultiByteStr^, s[1], cchMultiByte); + SetLength(s, cchMultiByte); + Move(lpMultiByteStr^, s[1], cchMultiByte); end; + end; if CodePage = CP_UTF8 then begin w := UTF8Decode(s); diff --git a/components/thtmlport/package/htmlun2.pas b/components/thtmlport/package/htmlun2.pas index cf2995c8c..b0b6a694a 100755 --- a/components/thtmlport/package/htmlun2.pas +++ b/components/thtmlport/package/htmlun2.pas @@ -693,12 +693,11 @@ var ExtS: TSize; Ints: ^Integers; L, H, I: integer; - begin -Extent := 0; -Result := 0; -if (Width <= 0) or (Max = 0) then - Exit; + Extent := 0; + Result := 0; + if (Width <= 0) or (Max = 0) then + Exit; {$IFDEF MSWINDOWS} //Only compile if GetTextExtentExPointW exists if not IsWin32Platform then diff --git a/components/thtmlport/package/styleun.pas b/components/thtmlport/package/styleun.pas index 46fcc9dc5..f43618590 100644 --- a/components/thtmlport/package/styleun.pas +++ b/components/thtmlport/package/styleun.pas @@ -2438,13 +2438,12 @@ if ColorStrings = nil then end; end; -function ColorFromString(S: string; NeedPound: boolean; var Color: TColor): boolean; {Translate StyleSheet color string to Color. If NeedPound is true, a '#' sign is required to preceed a hexidecimal value.} +function ColorFromString(S: string; NeedPound: boolean; var Color: TColor): boolean; const LastS: string = '?&%@'; LastColor: TColor = 0; - var I, Rd, Bl: integer; S1: string;