Permalink
Browse files

Add code-gen of charclass with ignoremark.

Missed a range check that could lead to chr being passed a -1 that was
meant to indicate index out of range.
  • Loading branch information...
1 parent 67ae0cf commit 8094c3d7482e89450049ab79467b75c9061cee30 @jnthn jnthn committed Jul 21, 2016
Showing with 4 additions and 0 deletions.
  1. +4 −0 src/vm/moar/QAST/QASTRegexCompilerMAST.nqp
@@ -504,11 +504,15 @@ class QAST::MASTRegexCompiler {
}
if $node.subtype eq 'ignoremark' || $node.subtype eq 'ignorecase+ignoremark' {
my $s0 := $!regalloc.fresh_s();
+ my $i1 := $!regalloc.fresh_i();
merge_ins(@ins, [
op('ordbaseat', $i0, %!reg<tgt>, %!reg<pos>),
+ op('lt_i', $i1, $i0, %!reg<zero>),
+ op('if_i', $i1, %!reg<fail>),
op('chr', $s0, $i0),
op($op, $s0, %!reg<zero>, sval($node[0]), %!reg<fail>),
]);
+ $!regalloc.release_register($i1, $MVM_reg_int64);
}
else {
nqp::push(@ins, op($op, %!reg<tgt>, %!reg<pos>, sval($node[0]), %!reg<fail>));

0 comments on commit 8094c3d

Please sign in to comment.