Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes segmentation fault when non-integer value of s is supplied

  • Loading branch information...
commit 32f9e79e7253edc8e158ab13835830a4fa75ca16 1 parent 9e3af78
Olaf Alders oalders authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/Plack/Middleware/QRCode.pm
10 lib/Plack/Middleware/QRCode.pm
View
@@ -34,13 +34,19 @@ sub call {
my $params = $req->parameters->mixed;
my %config = %{ $self->config };
- $config{size} = $params->{s};
+ $config{size} = $params->{s} if exists $params->{s};
$config{margin} = $params->{m};
my $pathinfo = substr $env->{'PATH_INFO'},1;
say STDERR "Generating QRCode for '" , $pathinfo , "'";
- return [ 500 , [ 'Content-type' => 'text/plain' ] , [ 'Please enter text for QRCode' ] ] unless $pathinfo;
+ my @error = ( 500 , [ 'Content-type' => 'text/plain' ] );
+
+ return [ @error , [ 'Please enter text for QRCode' ] ] unless $pathinfo;
+
+ unless ( $config{size} > 0 ) {
+ return [ @error, [ 'Please enter an integer for size param' ] ];
+ }
my $qrcode = Imager::QRCode->new( %config );
my $img = $qrcode->plot( $pathinfo );
Please sign in to comment.
Something went wrong with that request. Please try again.