File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -309,7 +309,10 @@ impl<R: io::BufRead> Decompressor<R> {
309
309
#[ cfg( feature = "lzma" ) ]
310
310
CompressionMethod :: Lzma => Decompressor :: Lzma ( liblzma:: bufread:: XzDecoder :: new_stream (
311
311
reader,
312
- liblzma:: stream:: Stream :: new_lzma_decoder ( 0 ) . unwrap ( ) ,
312
+ // Use u64::MAX for unlimited memory usage, matching the previous behavior
313
+ // from lzma-rs. Using 0 would set the smallest memory limit, which is
314
+ // problematic in ancient liblzma versions (5.2.3 and earlier).
315
+ liblzma:: stream:: Stream :: new_lzma_decoder ( u64:: MAX ) . unwrap ( ) ,
313
316
) ) ,
314
317
#[ cfg( feature = "xz" ) ]
315
318
CompressionMethod :: Xz => Decompressor :: Xz ( liblzma:: bufread:: XzDecoder :: new ( reader) ) ,
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env rust-script
2
+
3
+ //! Simple test to verify the LZMA memory limit fix
4
+ //! This script tests that LZMA decompression works with the new unlimited memory setting
5
+
6
+ #[ cfg( feature = "lzma" ) ]
7
+ fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
8
+ println ! ( "Testing LZMA memory limit fix..." ) ;
9
+
10
+ // Test that we can create an LZMA decoder with u64::MAX memory limit
11
+ // This would fail in ancient liblzma versions if we used 0
12
+ let _stream = liblzma:: stream:: Stream :: new_lzma_decoder ( u64:: MAX ) ?;
13
+ println ! ( "✓ Successfully created LZMA decoder with unlimited memory (u64::MAX)" ) ;
14
+
15
+ // Test that the old problematic value would work too (for comparison)
16
+ // Note: This might fail in ancient versions, but should work in modern ones
17
+ let _stream_old = liblzma:: stream:: Stream :: new_lzma_decoder ( 0 ) ;
18
+ match _stream_old {
19
+ Ok ( _) => println ! ( "✓ Old parameter (0) also works in this liblzma version" ) ,
20
+ Err ( e) => println ! (
21
+ "⚠ Old parameter (0) fails as expected in ancient versions: {}" ,
22
+ e
23
+ ) ,
24
+ }
25
+
26
+ println ! ( "Test completed successfully!" ) ;
27
+ Ok ( ( ) )
28
+ }
You can’t perform that action at this time.
0 commit comments