From a4f7284a8a6c8b2fe4d84eb5569375e6e19f6351 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sun, 22 Dec 2019 23:08:26 -0600 Subject: [PATCH] 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 --- Symbol.pas | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Symbol.pas b/Symbol.pas index c89c5cc..c01fc69 100644 --- a/Symbol.pas +++ b/Symbol.pas @@ -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}