ruby-xz 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c92bf36556e0297676ad48820dc2ba25243e897ac3d4401d4a8ec89d695e77e4
4
- data.tar.gz: 77a1b46d9158f80b6ad28c68483a02835fcecb9ae5fa85f9dcda296630238ea2
3
+ metadata.gz: efe7c4ed9a4c30ce23e8328060b458e36a29b7b31d17528a4acb842c461a6b11
4
+ data.tar.gz: f8c55ee6bf356b87d8511ff45bfcc481b17bc8475477a7dd9df56b69c7185a6b
5
5
  SHA512:
6
- metadata.gz: 7830929d9fea616430f554cb2a2ae2ef95095b8cf5d90c19e70e5bba697f301a059071c9da83a926ed7654506ccbe317009147c11d444822a47f78f3592dbfbc
7
- data.tar.gz: fea094736b25633859b303a17402a59cd673c3fafa80614dd096f5053c92d09604a2e06fbf3a1d75e11e04a34b336a54ffe4bb8ae4231f4766417a49d4cec5c7
6
+ metadata.gz: b61b2e26837ce216cdc03286e3c52d4fd38a01f95d158556d0ed9ed4f347d289e575f6bdd5da236265ba4a37ee9c779f98db37f663edce2308a874e6cedd9a16
7
+ data.tar.gz: a93055f9f309a7adf464b392cd9e5ac2bce97ae9f97bf37fec16d5f537ac2cd6d590d88a9ab6e6786be586eed841137bba29946de90bbf601124c695556af003
data/HISTORY.rdoc CHANGED
@@ -1,11 +1,17 @@
1
1
  = Version history
2
2
 
3
+ == 1.0.3 (2022-03-28)
4
+ * *Fix* a number of memory leaks by freeing allocated liblzma data structures
5
+ (Issue Quintus#20 reported by xTRiM, PR win93#7 by Alex Gittemeier)
6
+
3
7
  == 1.0.2 (2021-11-28)
4
- * Fix a deprecation warning and some other gemspec concerns (PR win93#6 by Alex Gittemeier)
8
+ * *Fix* a deprecation warning and some other gemspec concerns
9
+ (Issue win93#5, PR win93#6 by Alex Gittemeier)
5
10
 
6
11
  == 1.0.1 (2021-11-13)
7
- * Fix a buffer overflow error in XZ::Stream (PR Quintus#17 by genail)
8
- * Fix an issue with transcode_options that was introduced by Ruby 3 (PR win93#1 by Alex Gittemeier)
12
+ * *Fix* a buffer overflow error in XZ::Stream (PR Quintus#17 by genail)
13
+ * *Fix* an issue with transcode_options that was introduced by Ruby 3
14
+ (PR win93#1 by Alex Gittemeier)
9
15
  * Update project README, gemspec, and other metadata to reflect a change in
10
16
  maintainership. All prior releases were released by Marvin Gülker.
11
17
 
data/README.md CHANGED
@@ -110,7 +110,7 @@ To release a new version:
110
110
  - Switch to the `development` branch.
111
111
  - Bump `lib/xz/version.rb`, run `bundle install`, then commit the result.
112
112
  - Switch to the `stable` branch.
113
- - Run `git merge --no-ff development`
113
+ - Run `git merge development`
114
114
  - Run `rake release`, which will create/push a git tag and publish the `.gem`
115
115
  file to [rubygems.org].
116
116
 
data/lib/xz/stream.rb CHANGED
@@ -155,9 +155,9 @@ class XZ::Stream
155
155
  # Reset internal state
156
156
  @pos = @lineno = 0
157
157
  @finished = false
158
-
159
- # Allocate a new lzma stream (subclasses will configure it).
160
158
  @lzma_stream = XZ::LibLZMA::LZMAStream.malloc
159
+ @input_buffer_p = Fiddle::Pointer.malloc(XZ::CHUNK_SIZE)
160
+ @output_buffer_p = Fiddle::Pointer.malloc(XZ::CHUNK_SIZE)
161
161
  XZ::LibLZMA::LZMA_STREAM_INIT(@lzma_stream)
162
162
 
163
163
  0 # Mimic IO#rewind's return value
@@ -211,6 +211,9 @@ class XZ::Stream
211
211
  # Clean up the lzma_stream structure's internal memory.
212
212
  # This would belong into a destructor if Ruby had that.
213
213
  XZ::LibLZMA.lzma_end(@lzma_stream)
214
+ Fiddle.free @lzma_stream.to_ptr
215
+ Fiddle.free @input_buffer_p
216
+ Fiddle.free @output_buffer_p
214
217
  @finished = true
215
218
 
216
219
  @delegate_io
data/lib/xz/version.rb CHANGED
@@ -28,5 +28,5 @@
28
28
 
29
29
  module XZ
30
30
  # The version of this library.
31
- VERSION = '1.0.2'
31
+ VERSION = '1.0.3'
32
32
  end
data/lib/xz.rb CHANGED
@@ -218,8 +218,10 @@ module XZ
218
218
  end
219
219
 
220
220
  LibLZMA.lzma_end(stream.to_ptr)
221
+ res = stream.total_out if block_given?
221
222
 
222
- block_given? ? stream.total_out : res
223
+ Fiddle.free stream.to_ptr
224
+ res
223
225
  end
224
226
  alias decode_stream decompress_stream
225
227
 
@@ -317,8 +319,10 @@ module XZ
317
319
  end
318
320
 
319
321
  LibLZMA.lzma_end(stream.to_ptr)
322
+ res = stream.total_out if block_given?
320
323
 
321
- block_given? ? stream.total_out : res
324
+ Fiddle.free stream.to_ptr
325
+ res
322
326
  end
323
327
  alias encode_stream compress_stream
324
328
 
@@ -458,8 +462,8 @@ module XZ
458
462
  # time--this is needed to allow (de-)compressing of very large
459
463
  # files that can't be loaded fully into memory.
460
464
  def lzma_code(io, stream)
461
- input_buffer_p = Fiddle::Pointer.malloc(CHUNK_SIZE) # automatically freed by fiddle on GC
462
- output_buffer_p = Fiddle::Pointer.malloc(CHUNK_SIZE) # automatically freed by fiddle on GC
465
+ input_buffer_p = Fiddle::Pointer.malloc(CHUNK_SIZE)
466
+ output_buffer_p = Fiddle::Pointer.malloc(CHUNK_SIZE)
463
467
 
464
468
  while str = io.read(CHUNK_SIZE)
465
469
  input_buffer_p[0, str.bytesize] = str
@@ -502,6 +506,9 @@ module XZ
502
506
  break unless stream.avail_out == 0
503
507
  end #loop
504
508
  end #while
509
+
510
+ Fiddle.free input_buffer_p
511
+ Fiddle.free output_buffer_p
505
512
  end #lzma_code
506
513
 
507
514
  # Checks for errors and warnings that can be derived from the
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-xz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marvin Gülker
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-11-29 00:00:00.000000000 Z
12
+ date: 2022-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitar
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
- rubygems_version: 3.2.22
112
+ rubygems_version: 3.3.7
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: XZ compression via liblzma for Ruby, using fiddle.