summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--ext/zlib/zlib.c12
-rw-r--r--test/zlib/test_zlib.rb6
-rw-r--r--version.h2
4 files changed, 22 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index b24eef5254..af260ed19a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu Aug 29 21:51:33 2013 Eric Hodel <drbrain@segment7.net>
+
+ * ext/zlib/zlib.c (zstream_run): Fix handling of deflate streams that
+ need a dictionary but are being decompressed by Zlib::Inflate.inflate
+ (which has no option to set a dictionary). Now Zlib::NeedDict is
+ raised instead of crashing. [ruby-trunk - Bug #8829]
+ * test/zlib/test_zlib.rb (TestZlibInflate): Test for the above.
+
Thu Aug 29 21:28:56 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_insnhelper.c (vm_call_method): a method entry refers the based
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 69fd6769fa..8430481108 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -1074,11 +1074,13 @@ loop:
}
if (err == Z_NEED_DICT) {
VALUE self = (VALUE)z->stream.opaque;
- VALUE dicts = rb_ivar_get(self, id_dictionaries);
- VALUE dict = rb_hash_aref(dicts, rb_uint2inum(z->stream.adler));
- if (!NIL_P(dict)) {
- rb_inflate_set_dictionary(self, dict);
- goto loop;
+ if (self) {
+ VALUE dicts = rb_ivar_get(self, id_dictionaries);
+ VALUE dict = rb_hash_aref(dicts, rb_uint2inum(z->stream.adler));
+ if (!NIL_P(dict)) {
+ rb_inflate_set_dictionary(self, dict);
+ goto loop;
+ }
}
}
raise_zlib_error(err, z->stream.msg);
diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb
index 7b3ef2fc79..b4fe5abc30 100644
--- a/test/zlib/test_zlib.rb
+++ b/test/zlib/test_zlib.rb
@@ -232,6 +232,12 @@ if defined? Zlib
end
class TestZlibInflate < Test::Unit::TestCase
+ def test_class_inflate_dictionary
+ assert_raises(Zlib::NeedDict) do
+ Zlib::Inflate.inflate([0x08,0x3C,0x0,0x0,0x0,0x0].pack("c*"))
+ end
+ end
+
def test_initialize
assert_raise(Zlib::StreamError) { Zlib::Inflate.new(-1) }
diff --git a/version.h b/version.h
index 5e5a28cfc3..e7f30c223d 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2013-08-29"
-#define RUBY_PATCHLEVEL 298
+#define RUBY_PATCHLEVEL 299
#define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 8