From 20a534e63f6ef0d78ec07da0f17d849a5315efab Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 17 Mar 2013 14:24:50 +0000 Subject: [PATCH] * fixed code which causes range check errors when compiled with -Cr git-svn-id: trunk@23889 - --- compiler/ogbase.pas | 3 +++ compiler/scanner.pas | 18 +++++++++++++----- compiler/x86/itx86int.pas | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/compiler/ogbase.pas b/compiler/ogbase.pas index 7085765248..bb226fb567 100644 --- a/compiler/ogbase.pas +++ b/compiler/ogbase.pas @@ -1315,7 +1315,10 @@ implementation hstab.strpos:=1; hstab.ntype:=0; hstab.nother:=0; +{$push}{$R-} + { for jwawindows.pas, this causes an range check error, it contains too much stab symbols } hstab.ndesc:=(StabsSec.Size div sizeof(TObjStabEntry))-1; +{$pop} hstab.nvalue:=StabStrSec.Size; MaybeSwapStab(hstab); StabsSec.Data.seek(0); diff --git a/compiler/scanner.pas b/compiler/scanner.pas index 0e649bc518..791f613873 100644 --- a/compiler/scanner.pas +++ b/compiler/scanner.pas @@ -2629,13 +2629,15 @@ In case not, the value returned can be arbitrary. _CWSTRING : begin tokenwritesizeint(patternw^.len); - recordtokenbuf.write(patternw^.data^,patternw^.len*sizeof(tcompilerwidechar)); + if patternw^.len>0 then + recordtokenbuf.write(patternw^.data^,patternw^.len*sizeof(tcompilerwidechar)); end; _CSTRING: begin len:=length(cstringpattern); tokenwritesizeint(len); - recordtokenbuf.write(cstringpattern[1],len); + if len>0 then + recordtokenbuf.write(cstringpattern[1],len); end; _CCHAR, _INTCONST, @@ -2731,7 +2733,8 @@ In case not, the value returned can be arbitrary. begin wlen:=tokenreadsizeint; setlengthwidestring(patternw,wlen); - replaytokenbuf.read(patternw^.data^,patternw^.len*sizeof(tcompilerwidechar)); + if wlen>0 then + replaytokenbuf.read(patternw^.data^,patternw^.len*sizeof(tcompilerwidechar)); orgpattern:=''; pattern:=''; cstringpattern:=''; @@ -2739,8 +2742,13 @@ In case not, the value returned can be arbitrary. _CSTRING: begin wlen:=tokenreadsizeint; - setlength(cstringpattern,wlen); - replaytokenbuf.read(cstringpattern[1],wlen); + if wlen>0 then + begin + setlength(cstringpattern,wlen); + replaytokenbuf.read(cstringpattern[1],wlen); + end + else + cstringpattern:=''; orgpattern:=''; pattern:=''; end; diff --git a/compiler/x86/itx86int.pas b/compiler/x86/itx86int.pas index 9bf81abd25..b8b8e21248 100644 --- a/compiler/x86/itx86int.pas +++ b/compiler/x86/itx86int.pas @@ -72,7 +72,7 @@ implementation else r := m; end; - if int_regname_table[int_regname_index[r]]=s then + if (r<=high(tregisterindex)) and (int_regname_table[int_regname_index[r]]=s) then findreg_by_intname:=int_regname_index[r] else findreg_by_intname:=0;