[pypy-commit] pypy default: add missing check (fixes crash in scipy tests)

mattip pypy.commits at gmail.com
Tue Mar 26 15:22:39 EDT 2019


Author: Matti Picus <matti.picus at gmail.com>
Branch: 
Changeset: r96351:66a0b0d41728
Date: 2019-03-26 21:09 +0200
http://bitbucket.org/pypy/pypy/changeset/66a0b0d41728/

Log:	add missing check (fixes crash in scipy tests)

diff --git a/pypy/module/zlib/interp_zlib.py b/pypy/module/zlib/interp_zlib.py
--- a/pypy/module/zlib/interp_zlib.py
+++ b/pypy/module/zlib/interp_zlib.py
@@ -351,6 +351,9 @@
             if length <= 0:
                 raise oefmt(space.w_ValueError,
                             "length must be greater than zero")
+        if not self.stream:
+            raise zlib_error(space,
+                             "compressor object already flushed")
         data = self.unconsumed_tail
         try:
             self.lock()
diff --git a/pypy/module/zlib/test/test_zlib.py b/pypy/module/zlib/test/test_zlib.py
--- a/pypy/module/zlib/test/test_zlib.py
+++ b/pypy/module/zlib/test/test_zlib.py
@@ -356,3 +356,11 @@
         compressor = self.zlib.compressobj()
         compressor.flush()
         raises(ValueError, compressor.copy)
+
+    def test_double_flush(self):
+        import zlib
+        x = b'x\x9cK\xcb\xcf\x07\x00\x02\x82\x01E'  # 'foo'
+        dco = zlib.decompressobj()
+        dco.decompress(x)
+        dco.flush()
+        raises(self.zlib.error, dco.flush)


More information about the pypy-commit mailing list