diff --git a/Changes b/Changes index 2d925e0..8bbaf93 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,15 @@ Changes ======= +{{$NEXT}} + - Fix rt#94173 by freeing the handler at finish time + - Use Minilla for packaging the dist + +0.00006 - 20 Oct 2012 + - No code change + - Upgrade to Module::Install 1.06 + (see http://weblog.bulknews.net/post/33907905561/do-not-ship-modules-with-module-install-1-04) + 0.00005 - 28 Feb 2011 - Remove auto_include, and thus remove Test::More (rt #75361) diff --git a/lib/XML/LibXML/SAX/ChunkParser.pm b/lib/XML/LibXML/SAX/ChunkParser.pm index bd2bbf8..f07bf80 100644 --- a/lib/XML/LibXML/SAX/ChunkParser.pm +++ b/lib/XML/LibXML/SAX/ChunkParser.pm @@ -4,16 +4,21 @@ use base qw(XML::SAX::Base); use XML::LibXML; use Carp qw(croak); -our $VERSION = '0.00005'; +our $VERSION = '0.00006'; sub DESTROY { my $self = shift; + $self->clean_parser; +} + +sub clean_parser { + my $self = shift; - my $option = $self->{ParserOptions}; + my $option = delete $self->{ParserOptions}; if (! $option) { return; } - my $parser = $option->{LibParser}; + my $parser = delete $option->{LibParser}; if (! $parser) { return; } @@ -21,17 +26,26 @@ sub DESTROY { $parser->set_handler( undef ); } -sub parse_chunk { - my ($self, $chunk) = @_; +sub get_parser { + my $self = shift; my $options = $self->{ParserOptions}; if (! $options) { $options = {}; - $options->{LibParser} = XML::LibXML->new; $self->{ParserOptions} = $options; } + my $parser = $options->{LibParser}; - $parser->set_handler($self); + if (! $parser) { + $parser = $options->{LibParser} = XML::LibXML->new; + $parser->set_handler($self); + } + return $parser; +} +sub parse_chunk { + my ($self, $chunk) = @_; + + my $parser = $self->get_parser(); eval { $parser->parse_chunk( $chunk ); }; @@ -47,14 +61,13 @@ sub parse_chunk { sub finish { my $self = shift; - my $options = $self->{ParserOptions}; - if (! $options) { - $options->{LibParser} = XML::LibXML->new; - } - my $parser = $options->{LibParser}; + + my $parser = $self->get_parser(); if ($parser) { $parser->parse_chunk("", 1); } + + $self->clean_parser(); } 1;