]> iEval git - io-compress-brotli.git/commitdiff
Allow only window values between kBrotliMinWindowBits and kBrotliMaxindowBits
authorQuim Rovira <joaquim.rovira@booking.com>
Mon, 15 Aug 2016 16:05:21 +0000 (18:05 +0200)
committerQuim Rovira <joaquim.rovira@booking.com>
Mon, 15 Aug 2016 16:05:21 +0000 (18:05 +0200)
Brotli.xs

index c4660198661c43425f6498c351733c26e82b4875..8de3dd525c6cf371c2fce2cde24096e05b7d829a 100644 (file)
--- a/Brotli.xs
+++ b/Brotli.xs
@@ -102,7 +102,10 @@ SV* bro(buffer, quality=BROTLI_DEFAULT_QUALITY, lgwin=BROTLI_DEFAULT_WINDOW)
     BROTLI_BOOL result;
   CODE:
     if( quality < BROTLI_MIN_QUALITY || quality > BROTLI_MAX_QUALITY ) {
-               croak("Invalid quality value");
+        croak("Invalid quality value");
+    }
+    if( lgwin < kBrotliMinWindowBits || lgwin > kBrotliMaxWindowBits ) {
+        croak("Invalid window value");
     }
     decoded_buffer = (uint8_t*) SvPV(buffer, decoded_size);
     encoded_size = BrotliEncoderMaxCompressedSize(decoded_size);
@@ -137,6 +140,9 @@ SV* BrotliEncoderSetWindow(state, window)
     SV* state
     U32 window
   CODE:
+    if( window < kBrotliMinWindowBits || window > kBrotliMaxWindowBits ) {
+        croak("Invalid window value");
+    }
     if( BrotliEncoderSetParameter((BrotliEncoderState*) SvIV(state), BROTLI_PARAM_LGWIN, window) )
         RETVAL = newSVuv(1);
     else
@@ -149,7 +155,7 @@ SV* BrotliEncoderSetQuality(state, quality)
     U32 quality
   CODE:
     if( quality < BROTLI_MIN_QUALITY || quality > BROTLI_MAX_QUALITY ) {
-               croak("Invalid quality value");
+        croak("Invalid quality value");
     }
     if( BrotliEncoderSetParameter((BrotliEncoderState*) SvIV(state), BROTLI_PARAM_QUALITY, quality) )
         RETVAL = newSVuv(1);
This page took 0.028175 seconds and 4 git commands to generate.