diff --git a/compiler/pgenutil.pas b/compiler/pgenutil.pas index 4804995dbb..1829ce335a 100644 --- a/compiler/pgenutil.pas +++ b/compiler/pgenutil.pas @@ -813,6 +813,9 @@ uses st : TSymtable; i : longint; begin + { since commit 48986 deflist might have NIL entries } + if not assigned(def) then + exit; case def.typ of procdef: tprocdef(def).forwarddef:=false; diff --git a/compiler/pmodules.pas b/compiler/pmodules.pas index 60f93e6ae4..d5037f7d60 100644 --- a/compiler/pmodules.pas +++ b/compiler/pmodules.pas @@ -618,6 +618,9 @@ implementation for i:=current_module.localsymtable.deflist.count-1 downto 0 do begin def:=tdef(current_module.localsymtable.deflist[i]); + { since commit 48986 deflist might have NIL entries } + if not assigned(def) then + continue; { this also frees def, as the defs are owned by the symtable } if not def.is_registered and not(df_not_registered_no_free in def.defoptions) then diff --git a/compiler/wasm32/agllvmmc.pas b/compiler/wasm32/agllvmmc.pas index 4468a56f27..95db60e14b 100644 --- a/compiler/wasm32/agllvmmc.pas +++ b/compiler/wasm32/agllvmmc.pas @@ -70,31 +70,36 @@ implementation procedure TLLVMMachineCodePlaygroundAssembler.WriteImports; var i : integer; + def : tdef; proc : tprocdef; list : TAsmList; cur_unit: tused_unit; begin for i:=0 to current_module.deflist.Count-1 do - if assigned(current_module.deflist[i]) and (tdef(current_module.deflist[i]).typ=procdef) then - begin - proc := tprocdef(current_module.deflist[i]); - if (po_external in proc.procoptions) and assigned(proc.import_dll) then - begin - //WriteProcDef(proc); - list:=TAsmList.Create; - thlcgwasm(hlcg).g_procdef(list,proc); - WriteTree(list); - list.free; - writer.AsmWrite(#9'.import_module'#9); - writer.AsmWrite(proc.mangledname); - writer.AsmWrite(', '); - writer.AsmWriteLn(proc.import_dll^); - writer.AsmWrite(#9'.import_name'#9); - writer.AsmWrite(proc.mangledname); - writer.AsmWrite(', '); - writer.AsmWriteLn(proc.import_name^); - end; - end; + begin + def:=tdef(current_module.deflist[i]); + { since commit 48986 deflist might have NIL entries } + if assigned(def) and (def.typ=procdef) then + begin + proc := tprocdef(def); + if (po_external in proc.procoptions) and assigned(proc.import_dll) then + begin + //WriteProcDef(proc); + list:=TAsmList.Create; + thlcgwasm(hlcg).g_procdef(list,proc); + WriteTree(list); + list.free; + writer.AsmWrite(#9'.import_module'#9); + writer.AsmWrite(proc.mangledname); + writer.AsmWrite(', '); + writer.AsmWriteLn(proc.import_dll^); + writer.AsmWrite(#9'.import_name'#9); + writer.AsmWrite(proc.mangledname); + writer.AsmWrite(', '); + writer.AsmWriteLn(proc.import_name^); + end; + end; + end; list:=TAsmList.Create; cur_unit:=tused_unit(usedunits.First); while assigned(cur_unit) do diff --git a/compiler/wasm32/agwat.pas b/compiler/wasm32/agwat.pas index 7d40c64936..13684044dd 100644 --- a/compiler/wasm32/agwat.pas +++ b/compiler/wasm32/agwat.pas @@ -957,14 +957,17 @@ implementation procedure TWabtTextAssembler.WriteImports; var i : integer; + def : tdef; proc : tprocdef; sym : tsym; j : integer; psym : tprocsym; begin for i:=0 to current_module.deflist.Count-1 do begin - if tdef(current_module.deflist[i]).typ = procdef then begin - proc := tprocdef(current_module.deflist[i]); + def:=tdef(current_module.deflist[i]); + { since commit 48986 deflist might have NIL entries } + if assigned(def) and (def.typ=procdef) then begin + proc := tprocdef(def); if (po_external in proc.procoptions) and assigned(proc.import_dll) then begin writer.AsmWrite(#9'(import "'); writer.AsmWrite(proc.import_dll^);