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
1 changed files with 3 additions and 3 deletions

View File

@ -1352,7 +1352,7 @@ lUseGlobalPool := useGlobalPool;
tk.name := name;
tk.symbolPtr := nil;
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;
useGlobalPool := true;
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}
else if (itype^.kind in [structType,unionType]) and (itype^.fieldList = nil)
and doingParameters then begin
else if (itype <> nil) and (itype^.kind in [structType,unionType])
and (itype^.fieldList = nil) and doingParameters then begin
useGlobalPool := true;
end; {else if}
if noDeclarations then begin {if we need a symbol table, create it}