When an operand is missing, synthesize a "0" operand for post-error processing.

This ensures consistent behavior and avoids null-pointer dereferences in some cases.
This commit is contained in:
Stephen Heumann 2019-12-23 14:12:44 -06:00
parent b0b2b3fa91
commit 13a14d9389

View File

@ -874,12 +874,17 @@ var
if stack = nil then begin if stack = nil then begin
Error(36); Error(36);
errorFound := true; errorFound := true;
Pop := nil; new(stack); {synthesize the missing token}
end {if} stack^.token.class := intConstant;
else begin stack^.token.kind := intconst;
Pop := stack; stack^.token.ival := 0;
stack := stack^.next; stack^.next := nil;
end; {else} stack^.left := nil;
stack^.middle := nil;
stack^.right := nil;
end; {if}
Pop := stack;
stack := stack^.next;
end; {Pop} end; {Pop}