[3.0-beta2] AIOOBE in string.match with balanced pattern
Brought to you by:
ian_farmer,
jim_roseborough
The following causes an ArrayIndexOutOfBoundsException:
(""):match("%b''")
It should simply return nil (for no match). The following seems to fix it,
but I cannot really claim to have fully understood the pattern matcher, so
an expert opinion on the patch would be appreciated.
@@ -1155,7 +1155,7 @@ public class StringLib extends TwoArgFunction {
if ( poff == plen || poff + 1 == plen ) {
error( "unbalanced pattern" );
}
- if ( s.luaByte( soff ) != p.luaByte( poff ) )
+ if ( soff >= s.length() || s.luaByte( soff ) != p.luaByte( poff ) )
return -1;
else {
int b = p.luaByte( poff );
PS: this is in 3.0-beta2.
Any news on this bug? It seems that 3.0 still has it. :-(
A fix for this was check in on 3/9/2014, and the supplied code fragment passes when I test with luaj 3.0, so I believe this is fixed.
If there is some other pattern that triggers a similar error, please add to the bug report so I can improve the tests.