Skip to content

Commit

Permalink
split: prevent a panic in some cases with \G
Browse files Browse the repository at this point in the history
  • Loading branch information
tonycoz committed Sep 20, 2023
1 parent ea05091 commit 1d3e71c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pp.c
Original file line number Diff line number Diff line change
Expand Up @@ -6877,6 +6877,8 @@ PP_wrapped(pp_split,
else
trailing_empty = 0;
} else {
if (m < s)
m = s;
dstr = newSVpvn_flags(s, m-s, flags);
XPUSHs(dstr);
}
Expand Down
3 changes: 2 additions & 1 deletion t/op/split.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ BEGIN {
require './charset_tools.pl';
}

plan tests => 197;
plan tests => 198;

$FS = ':';

Expand Down Expand Up @@ -725,3 +725,4 @@ SKIP: {
}, "special-case pattern for $prog");
}
}
fresh_perl_is('split /00|0\G/, "000"', '', {}, "split with \\G doesn't panic");

0 comments on commit 1d3e71c

Please sign in to comment.