Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 32f9e79e7253edc8e158ab13835830a4fa75ca16 1 parent 9e3af78
Olaf Alders authored November 08, 2011

Showing 1 changed file with 8 additions and 2 deletions. Show diff stats Hide diff stats

  1. 10  lib/Plack/Middleware/QRCode.pm
10  lib/Plack/Middleware/QRCode.pm
@@ -34,13 +34,19 @@ sub call {
34 34
     my $params = $req->parameters->mixed;
35 35
     my %config = %{ $self->config };
36 36
 
37  
-    $config{size} = $params->{s};
  37
+    $config{size} = $params->{s} if exists $params->{s};
38 38
     $config{margin} = $params->{m};
39 39
 
40 40
     my $pathinfo = substr $env->{'PATH_INFO'},1;
41 41
     say STDERR "Generating QRCode for '" , $pathinfo , "'";
42 42
 
43  
-    return [ 500 , [ 'Content-type' => 'text/plain' ] , [ 'Please enter text for QRCode' ] ] unless $pathinfo;
  43
+    my @error = ( 500 , [ 'Content-type' => 'text/plain' ] );
  44
+
  45
+    return [ @error , [ 'Please enter text for QRCode' ] ] unless $pathinfo;
  46
+
  47
+    unless ( $config{size} > 0 ) {
  48
+        return [ @error, [ 'Please enter an integer for size param' ] ];
  49
+    }
44 50
 
45 51
     my $qrcode = Imager::QRCode->new( %config );
46 52
     my $img = $qrcode->plot( $pathinfo );

0 notes on commit 32f9e79

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