Avoid overflow in computation of whether a case statement is sparse.

If the difference between the minimum and maximum values in a case statement was greater than 32767, then the subtraction in this computation would overflow. That would cause the case statement to be treated as non-sparse, so a jump table would be generated for it, but that jump table would be very large, so it would overflow the object buffer and cause an error.
This commit is contained in:
Stephen Heumann 2022-07-24 19:50:56 -05:00
parent d660acc061
commit e42be0deeb
1 changed files with 1 additions and 1 deletions

View File

@ -3737,7 +3737,7 @@ end; {DoConstant}
Gen1(dc_lab, lcix);
if fstptr <> nil then begin {if there are labels...}
lmin := fstptr^.cslab;
if (lmax - lmin) div lcount > sparse then begin
if (ord4(lmax) - lmin) div lcount > sparse then begin
{use if-else for sparse case statements}
while fstptr <> nil do begin