* fix possible range check errors, resolves #27461

git-svn-id: trunk@29743 -
This commit is contained in:
florian 2015-02-17 21:14:47 +00:00
parent 0dfbba86f3
commit 726a78be08
2 changed files with 5 additions and 3 deletions

View File

@ -1205,7 +1205,7 @@ Begin
begin begin
if tconstsym(srsym).consttyp=constord then if tconstsym(srsym).consttyp=constord then
Begin Begin
l:=tconstsym(srsym).value.valueord.svalue; l:=aint(tconstsym(srsym).value.valueord.svalue);
SearchIConstant:=TRUE; SearchIConstant:=TRUE;
exit; exit;
end; end;

View File

@ -3420,8 +3420,10 @@ implementation
constructor tarraydef.create_from_pointer(def:tpointerdef); constructor tarraydef.create_from_pointer(def:tpointerdef);
begin begin
{ use -1 so that the elecount will not overflow } { divide by the element size and do -1 so the array will have a valid size,
self.create(0,high(asizeint)-1,ptrsinttype); further, the element size might be 0 e.g. for empty records, so use max(...,1)
to avoid a division by zero }
self.create(0,(high(asizeint) div max(def.pointeddef.size,1))-1,ptrsinttype);
arrayoptions:=[ado_IsConvertedPointer]; arrayoptions:=[ado_IsConvertedPointer];
setelementdef(def.pointeddef); setelementdef(def.pointeddef);
end; end;