Skip to content

Commit 1f3ea25

Browse files
committed
Fix crash on variable-index goto with lazy-declared array label
When goto label[expr] used a variable expression and the label was lazy-created (no explicit label declaration with range), the compiler passed a sentinel with empty range (lo=1, hi=0) to generate_arraylabel_goto which built an empty case node, causing an access violation during later processing.
1 parent ced47f1 commit 1f3ea25

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

compiler/pstatmnt.pas

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,8 +2217,16 @@ ((p.resultdef.typ=recorddef) or
22172217
end
22182218
else
22192219
begin
2220-
{ Variable index - generate if-chain for jump }
2221-
code:=generate_arraylabel_goto(tlabelsym(srsym),p);
2220+
{ Variable index - generate dispatch for jump.
2221+
Requires explicit label declaration with range. }
2222+
if tlabelsym(srsym).arraylabel_lo<=tlabelsym(srsym).arraylabel_hi then
2223+
code:=generate_arraylabel_goto(tlabelsym(srsym),p)
2224+
else
2225+
begin
2226+
p.free;
2227+
Message(sym_e_label_not_found);
2228+
code:=cerrornode.create;
2229+
end;
22222230
end;
22232231
end;
22242232
end;

0 commit comments

Comments
 (0)