Skip to content
Browse files

Fix segfault on multiple streams..

  • Loading branch information...
1 parent f7ee3f3 commit 55e83030f2e636c3e2304cac2cd7b595e0685486 @mnunberg committed Sep 18, 2012
Showing with 32 additions and 2 deletions.
  1. +2 −2 SL.xs
  2. +30 −0 t/b100-gh1.t
View
4 SL.xs
@@ -589,8 +589,8 @@ static void body_pop_callback(jsonsl_t jsn,
#undef INSERT_STRING
- if (state->sv == pjsn->root && pjsn->njprs == 0) {
- if (!pjsn->options.object_drip) {
+ if (state->sv == pjsn->root) {
+ if (pjsn->njprs == 0 && pjsn->options.object_drip == 0) {
av_push(pjsn->results, newRV_noinc(pjsn->root));
} /* otherwise, already pushed */
pjsn->root = NULL;
View
30 t/b100-gh1.t
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+use Test::More;
+use JSON::SL;
+
+my $input = "[ 5 ], [ 6 ], { \"foo\" : \"bar\" }";
+my $p = JSON::SL->new();
+$p->set_jsonpointer(["/^"]);
+$p->feed($input);
+my @res = $p->fetch();
+
+my $exp = [
+ {
+ 'Value' => 5,
+ 'JSONPointer' => '/^',
+ 'Path' => '/0'
+ },
+ {
+ 'Value' => 6,
+ 'JSONPointer' => '/^',
+ 'Path' => '/0'
+ },
+ {
+ 'Value' => 'bar',
+ 'JSONPointer' => '/^',
+ 'Path' => '/foo'
+ }
+];
+
+is_deeply(\@res, $exp);
+done_testing();

0 comments on commit 55e8303

Please sign in to comment.
Something went wrong with that request. Please try again.