Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer not being initialized & used correctly #10

Open
horus opened this issue Dec 19, 2017 · 0 comments
Open

Buffer not being initialized & used correctly #10

horus opened this issue Dec 19, 2017 · 0 comments

Comments

@horus
Copy link

horus commented Dec 19, 2017

In file HTTP/Entity/Parser.pm L72

    my $buffer;
    if ($env->{'psgix.input.buffered'}) {
        # Just in case if input is read by middleware/apps beforehand
        $input->seek(0, 0);
    } else {
        $buffer = Stream::Buffered->new();
    }

later around L117:

       my $loaded = substr $chunk_buffer, 0, $chunk_len, ''; 
       $parser->add($loaded);
       $buffer->print($loaded);
       $chunk_buffer =~ s/^\015\012//;
       $length += $chunk_len;

If I understand the code correctly, when psgix.input.buffered is defined, the $buffer would not be initialized.

It should be checked before using, like L89:

    $buffer->print($chunk) if $buffer;

Otherwise, in some cases it will croak:

Can't call method "print" on an undefined value at /perl5/lib/perl5/HTTP/Entity/Parser.pm line 117

Hope this will be fixed soon, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant