Skip Menu |

This queue is for tickets about the JSON-Streaming-Reader CPAN distribution.

Report information
The Basics
Id: 68900
Status: new
Priority: 0/
Queue: JSON-Streaming-Reader

People
Owner: Nobody in particular
Requestors: rob [...] hoelz.ro
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.04
Fixed in: (no value)



Subject: Underrun causes strange errors
Hi, If you feed the following chunks into the event-based interface, it triggers an error event: "[" "null,428" "]" What seems to happen is that a buffer underrun is encountered after the second chunk, so the stream rolls back to the comma in the second chunk. On the next attempt, the comma is the first thing that is seen, so an "Unexpected comma" error is encountered. Attached is a test file that demonstrates this. Thanks, Rob
Subject: 06-underrun.t
use strict; use warnings; use Test::More tests => 3; use JSON::Streaming::Reader::TestUtil; compare_event_parse("[", "null,428", "]"); compare_event_parse("[", "null,428", "123]"); compare_event_parse("[", "null,\"foo", "bar\"]");
From: rob [...] hoelz.ro
I added a small fix; it doesn't cause any regressions in the tests, but please let me know if you find anything horribly wrong with it (it's attached as a patch). -Rob On Fri Jun 17 14:42:39 2011, hoelzro wrote: Show quoted text
> Hi, > > If you feed the following chunks into the event-based interface, it > triggers an error event: > > "[" > "null,428" > "]" > > What seems to happen is that a buffer underrun is encountered after > the second chunk, so the > stream rolls back to the comma in the second chunk. On the next > attempt, the comma is the > first thing that is seen, so an "Unexpected comma" error is > encountered. Attached is a test file > that demonstrates this. > > Thanks, > Rob
Subject: underrun-fix.patch
--- JSON-Streaming-Reader-0.04/lib/JSON/Streaming/Reader.pm 2009-06-10 21:07:54.000000000 -0500 +++ JSON-Streaming-Reader-0.04-rhoelz/lib/JSON/Streaming/Reader.pm 2011-06-17 14:01:53.000000000 -0500 @@ -92,6 +92,12 @@ if ($self->made_value) { $self->_require_char(','); + if($self->is_event_based) { + my $stream = $self->{stream}; + $stream->complete_reading; + $stream->begin_reading; + } + $self->_set_done_comma(); next; }