diff -rN -Nud old-JSON-2.11/lib/JSON/PP.pm new-JSON-2.11/lib/JSON/PP.pm
--- old-JSON-2.11/lib/JSON/PP.pm 2008-06-18 23:35:06.000000000 +0300
+++ new-JSON-2.11/lib/JSON/PP.pm 2008-06-18 23:35:06.000000000 +0300
@@ -1432,7 +1432,8 @@
}
}
elsif ( $s eq ']' or $s eq '}' ) {
- last unless ( --$self->{incr_nest} );
+ last if !$self->{incr_nest} # don't go below 0
+ or --$self->{incr_nest} == 0;
}
}
diff -rN -Nud old-JSON-2.11/t/19_incr.t new-JSON-2.11/t/19_incr.t
--- old-JSON-2.11/t/19_incr.t 2008-06-18 23:35:06.000000000 +0300
+++ new-JSON-2.11/t/19_incr.t 2008-06-18 23:35:06.000000000 +0300
@@ -3,7 +3,7 @@
use strict;
use Test::More;
-BEGIN { plan tests => 693 };
+BEGIN { plan tests => 697 };
BEGIN { $ENV{PERL_JSON_BACKEND} = 0; }
@@ -165,4 +165,17 @@
eval q{ !$coder->incr_parse (" [] ") }; ok ($@ =~ /maximum nesting/, "incdepth2 $@");
}
+{
+ my $coder = JSON->new;
+
+ my $res = eval { $coder->incr_parse("]") };
+ my $e = $@; # test more clobbers $@, we need it twice
+ ok(!$res, "unbalanced bracket" );
+ ok($e, "got error");
+ like( $e, qr/malformed/, "malformed json string error" );
+
+ $coder->incr_skip;
+
+ is_deeply(eval { $coder->incr_parse("[42]") }, [42], "valid data after incr_skip");
+}