From f67506f16755f21132bd292a968b5570809eea65 Mon Sep 17 00:00:00 2001 From: Jianbin Chen Date: Tue, 6 Dec 2022 14:39:33 -0800 Subject: [PATCH] Raise LZ4Error rather LZ4Internal::Error when the data is corrupted --- Gemfile | 2 +- VERSION | 2 +- lib/lz4-ruby.rb | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 67c889d..4e6ba73 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,6 @@ group :development do gem "rspec" gem "rdoc", "~> 3.12" gem "bundler" - gem "jeweler", "~> 1.8.3" + gem "jeweler", "~> 2.3.9" gem "rake-compiler", ">= 0" end diff --git a/VERSION b/VERSION index 87a0871..42045ac 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.3 \ No newline at end of file +0.3.4 diff --git a/lib/lz4-ruby.rb b/lib/lz4-ruby.rb index 879de8f..dbebea7 100644 --- a/lib/lz4-ruby.rb +++ b/lib/lz4-ruby.rb @@ -16,15 +16,15 @@ def self.compress(input, in_size = nil) def self.compressHC(input, in_size = nil) return _compress(input, in_size, true) end - + def self.decompress(input, in_size = nil, encoding = nil) in_size = input.bytesize if in_size == nil out_size, varbyte_len = decode_varbyte(input) if out_size < 0 || varbyte_len < 0 - raise "Compressed data is maybe corrupted" + raise LZ4Error, "Compressed data is maybe corrupted" end - + result = LZ4Internal::uncompress(input, in_size, varbyte_len, out_size) result.force_encoding(encoding) if encoding != nil