@@ -150,9 +150,9 @@ impl Compress {
150150 return Ok ( Status :: RunOk ) ;
151151 }
152152 self . inner . raw . next_in = input. as_ptr ( ) as * mut _ ;
153- self . inner . raw . avail_in = input. len ( ) as c_uint ;
153+ self . inner . raw . avail_in = input. len ( ) . min ( c_uint :: MAX as usize ) as c_uint ;
154154 self . inner . raw . next_out = output. as_mut_ptr ( ) as * mut _ ;
155- self . inner . raw . avail_out = output. len ( ) as c_uint ;
155+ self . inner . raw . avail_out = output. len ( ) . min ( c_uint :: MAX as usize ) as c_uint ;
156156 unsafe {
157157 match ffi:: BZ2_bzCompress ( & mut * self . inner . raw , action as c_int ) {
158158 ffi:: BZ_RUN_OK => Ok ( Status :: RunOk ) ,
@@ -225,9 +225,9 @@ impl Decompress {
225225 /// Decompress a block of input into a block of output.
226226 pub fn decompress ( & mut self , input : & [ u8 ] , output : & mut [ u8 ] ) -> Result < Status , Error > {
227227 self . inner . raw . next_in = input. as_ptr ( ) as * mut _ ;
228- self . inner . raw . avail_in = input. len ( ) as c_uint ;
228+ self . inner . raw . avail_in = input. len ( ) . min ( c_uint :: MAX as usize ) as c_uint ;
229229 self . inner . raw . next_out = output. as_mut_ptr ( ) as * mut _ ;
230- self . inner . raw . avail_out = output. len ( ) as c_uint ;
230+ self . inner . raw . avail_out = output. len ( ) . min ( c_uint :: MAX as usize ) as c_uint ;
231231 unsafe {
232232 match ffi:: BZ2_bzDecompress ( & mut * self . inner . raw ) {
233233 ffi:: BZ_OK => Ok ( Status :: Ok ) ,
0 commit comments