mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-09 21:48:35 +02:00
* fixed arithmetic overflow when loading the recorddef of large
(> high(aint)/8 bytes) records from ppu files git-svn-id: trunk@5595 -
This commit is contained in:
parent
22a372f10b
commit
26f81bfe08
@ -43,7 +43,7 @@ type
|
||||
{$endif Test_Double_checksum}
|
||||
|
||||
const
|
||||
CurrentPPUVersion=69;
|
||||
CurrentPPUVersion=70;
|
||||
|
||||
{ buffer sizes }
|
||||
maxentrysize = 1024;
|
||||
|
@ -2426,11 +2426,12 @@ implementation
|
||||
begin
|
||||
inherited ppuload(recorddef,ppufile);
|
||||
symtable:=trecordsymtable.create(0);
|
||||
trecordsymtable(symtable).datasize:=ppufile.getaint;
|
||||
trecordsymtable(symtable).fieldalignment:=shortint(ppufile.getbyte);
|
||||
trecordsymtable(symtable).recordalignment:=shortint(ppufile.getbyte);
|
||||
trecordsymtable(symtable).padalignment:=shortint(ppufile.getbyte);
|
||||
trecordsymtable(symtable).usefieldalignment:=shortint(ppufile.getbyte);
|
||||
{ requires usefieldalignment to be set }
|
||||
trecordsymtable(symtable).datasize:=ppufile.getaint;
|
||||
trecordsymtable(symtable).ppuload(ppufile);
|
||||
symtable.defowner:=self;
|
||||
isunion:=false;
|
||||
@ -2486,11 +2487,11 @@ implementation
|
||||
procedure trecorddef.ppuwrite(ppufile:tcompilerppufile);
|
||||
begin
|
||||
inherited ppuwrite(ppufile);
|
||||
ppufile.putaint(trecordsymtable(symtable).datasize);
|
||||
ppufile.putbyte(byte(trecordsymtable(symtable).fieldalignment));
|
||||
ppufile.putbyte(byte(trecordsymtable(symtable).recordalignment));
|
||||
ppufile.putbyte(byte(trecordsymtable(symtable).padalignment));
|
||||
ppufile.putbyte(byte(trecordsymtable(symtable).usefieldalignment));
|
||||
ppufile.putaint(trecordsymtable(symtable).datasize);
|
||||
ppufile.writeentry(ibrecorddef);
|
||||
trecordsymtable(symtable).ppuwrite(ppufile);
|
||||
end;
|
||||
|
@ -913,7 +913,9 @@ implementation
|
||||
procedure tabstractrecordsymtable.setdatasize(val: aint);
|
||||
begin
|
||||
_datasize:=val;
|
||||
databitsize:=val*8;
|
||||
if (usefieldalignment=bit_alignment) then
|
||||
{ can overflow in non bitpacked records }
|
||||
databitsize:=val*8;
|
||||
end;
|
||||
|
||||
{****************************************************************************
|
||||
@ -943,7 +945,8 @@ implementation
|
||||
storesize:=_datasize;
|
||||
storealign:=fieldalignment;
|
||||
_datasize:=offset;
|
||||
databitsize:=offset*8;
|
||||
if (usefieldalignment=bit_alignment) then
|
||||
databitsize:=offset*8;
|
||||
|
||||
{ We move the ownership of the defs and symbols to the new recordsymtable.
|
||||
The old unionsymtable keeps the references, but doesn't own the
|
||||
|
@ -1831,11 +1831,11 @@ begin
|
||||
ibrecorddef :
|
||||
begin
|
||||
readcommondef('Record definition');
|
||||
writeln(space,' DataSize : ',getaint);
|
||||
writeln(space,' FieldAlign : ',getbyte);
|
||||
writeln(space,' RecordAlign : ',getbyte);
|
||||
writeln(space,' PadAlign : ',getbyte);
|
||||
writeln(space,'UseFieldAlignment : ',getbyte);
|
||||
writeln(space,' DataSize : ',getaint);
|
||||
if not EndOfEntry then
|
||||
Writeln('!! Entry has more information stored');
|
||||
{read the record definitions and symbols}
|
||||
|
Loading…
Reference in New Issue
Block a user