Skip to content

Commit

Permalink
(perl #131562) correct large line numbers copying eval lines on #line
Browse files Browse the repository at this point in the history
Previously this used I32 for line numbers, which takes half the range
of line_t and folds it into negative numbers, leading to trying to store
the lines at negative indexes.

The while loop was also modified to stop storing if/when the line number
no longer fits into cop_line, or no longer fits into SSize_t (as a
positive number) since the index parameter to av_store() is a SSize_t.
  • Loading branch information
tonycoz committed Jan 21, 2019
1 parent 187a416 commit 515c395
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions toke.c
Original file line number Diff line number Diff line change
Expand Up @@ -1829,14 +1829,14 @@ S_incline(pTHX_ const char *s, const char *end)
}
else if (GvAV(cfgv)) {
AV * const av = GvAV(cfgv);
const I32 start = CopLINE(PL_curcop)+1;
I32 items = AvFILLp(av) - start;
const line_t start = CopLINE(PL_curcop)+1;
SSize_t items = AvFILLp(av) - start;
if (items > 0) {
AV * const av2 = GvAVn(gv2);
SV **svp = AvARRAY(av) + start;
I32 l = (I32)line_num+1;
while (items--)
av_store(av2, l++, SvREFCNT_inc(*svp++));
Size_t l = line_num+1;
while (items-- && l < SSize_t_MAX && l == (line_t)l)
av_store(av2, (SSize_t)l++, SvREFCNT_inc(*svp++));
}
}
}
Expand Down

0 comments on commit 515c395

Please sign in to comment.