From 4db26d14bdbc0af7de8495d1021a9cb94f1190b6 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Mon, 23 Dec 2019 21:33:27 -0600 Subject: [PATCH] Skip initializer processing for flexible array members. This could result in null pointer dereferences. --- Parser.pas | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Parser.pas b/Parser.pas index f0cd14a..0493823 100644 --- a/Parser.pas +++ b/Parser.pas @@ -3940,6 +3940,8 @@ var 2: end; arrayType: begin + elements := itype^.elements; + if elements = 0 then goto 1; {don't init flexible array member} if itype^.aType^.kind = scalarType then if itype^.aType^.baseType in [cgByte,cgUByte] then if iPtr^.iTree^.token.kind = stringConst then begin @@ -3955,7 +3957,6 @@ var iPtr := iPtr^.next; goto 1; end; {if} - elements := itype^.elements; itype := itype^.atype; if ZeroFill(elements, itype, count, iPtr) then begin if itype^.kind = enumType then