Avoid null pointer dereferences when processing K&R-style function parameter declarations.

These are initially entered into the symbol table with no known type (itype = nil), so this case should be accounted for in NewSymbol.

This typically would not cause a problem, but might if the zero page contained certain values
This commit is contained in:
Stephen Heumann 2019-12-22 23:08:26 -06:00
parent b88dc5b39c
commit a4f7284a8a

View File

@ -1352,7 +1352,7 @@ lUseGlobalPool := useGlobalPool;
tk.name := name; tk.name := name;
tk.symbolPtr := nil; tk.symbolPtr := nil;
if space <> fieldListSpace then begin {are we defining a function?} if space <> fieldListSpace then begin {are we defining a function?}
if itype^.kind = functionType then begin if (itype <> nil) and (itype^.kind = functionType) then begin
isGlobal := true; isGlobal := true;
useGlobalPool := true; useGlobalPool := true;
if class in [autosy, ident] then if class in [autosy, ident] then
@ -1376,8 +1376,8 @@ if space <> fieldListSpace then begin {are we defining a function?}
end; {if} end; {if}
end; {if} end; {if}
end {if} end {if}
else if (itype^.kind in [structType,unionType]) and (itype^.fieldList = nil) else if (itype <> nil) and (itype^.kind in [structType,unionType])
and doingParameters then begin and (itype^.fieldList = nil) and doingParameters then begin
useGlobalPool := true; useGlobalPool := true;
end; {else if} end; {else if}
if noDeclarations then begin {if we need a symbol table, create it} if noDeclarations then begin {if we need a symbol table, create it}