* stop updating llvmnextfieldindex once we have established that the current

typed constant does not match the equivalent LLVM definition (it's only
    used to check whether any emitted data's type differs from the LLVM
    definition's field types)
   o fixed a potential out-of-bounds access related to this: the index of the
     equivalent LLVM field kept getting increased and at some point we checked
     whether the current emitted data's type was different from the LLVM field
     type without verifying first that the LLVM equivalent field index was not
     yet beyond the number of LLVM equivalent fields

git-svn-id: trunk@35018 -
This commit is contained in:
Jonas Maebe 2016-11-29 21:54:25 +00:00
parent ee014fa4ff
commit 8cd84bd8e8

View File

@ -301,12 +301,13 @@ implementation
use a custom recorddef to emit this data } use a custom recorddef to emit this data }
if not(info.anonrecord) and if not(info.anonrecord) and
(info.def.typ<>procvardef) and (info.def.typ<>procvardef) and
(aggregate_kind(info.def)=tck_record) then (aggregate_kind(info.def)=tck_record) and
not info.doesnotmatchllvmdef then
begin begin
if not info.doesnotmatchllvmdef and if (info.llvmnextfieldindex>=tabstractrecordsymtable(tabstractrecorddef(info.def).symtable).llvmst.symdeflist.count) or
(info.llvmnextfieldindex<tabstractrecordsymtable(tabstractrecorddef(info.def).symtable).llvmst.symdeflist.count) and
not equal_defs(def,tabstractrecordsymtable(tabstractrecorddef(info.def).symtable).llvmst.entries_by_llvm_index[info.llvmnextfieldindex].def) then not equal_defs(def,tabstractrecordsymtable(tabstractrecorddef(info.def).symtable).llvmst.entries_by_llvm_index[info.llvmnextfieldindex].def) then
info.doesnotmatchllvmdef:=true; info.doesnotmatchllvmdef:=true
else
info.llvmnextfieldindex:=info.llvmnextfieldindex+1; info.llvmnextfieldindex:=info.llvmnextfieldindex+1;
end; end;
info.aggai.addvalue(stc); info.aggai.addvalue(stc);
@ -485,15 +486,18 @@ implementation
inherited; inherited;
info:=tllvmaggregateinformation(curagginfo); info:=tllvmaggregateinformation(curagginfo);
if assigned(info) and if assigned(info) and
was_aggregate then was_aggregate and
not info.doesnotmatchllvmdef then
begin begin
{ are we emitting data that does not match the equivalent data in { are we emitting data that does not match the equivalent data in
the llvm structure? If so, record this so that we know we have to the llvm structure? If so, record this so that we know we have to
use a custom recorddef to emit this data } use a custom recorddef to emit this data }
if not info.anonrecord and if not info.anonrecord and
(aggregate_kind(info.def)=tck_record) and (aggregate_kind(info.def)=tck_record) and
not equal_defs(def,tabstractrecordsymtable(tabstractrecorddef(info.def).symtable).llvmst.entries_by_llvm_index[info.llvmnextfieldindex].def) then ((info.llvmnextfieldindex>=tabstractrecordsymtable(tabstractrecorddef(info.def).symtable).llvmst.symdeflist.count) or
info.doesnotmatchllvmdef:=true; not equal_defs(def,tabstractrecordsymtable(tabstractrecorddef(info.def).symtable).llvmst.entries_by_llvm_index[info.llvmnextfieldindex].def)) then
info.doesnotmatchllvmdef:=true
else
info.llvmnextfieldindex:=info.llvmnextfieldindex+1; info.llvmnextfieldindex:=info.llvmnextfieldindex+1;
end; end;
end; end;