diff --git a/include/boost/beast/zlib/detail/deflate_stream.ipp b/include/boost/beast/zlib/detail/deflate_stream.ipp index 51698433..470c7d0d 100644 --- a/include/boost/beast/zlib/detail/deflate_stream.ipp +++ b/include/boost/beast/zlib/detail/deflate_stream.ipp @@ -360,7 +360,10 @@ doWrite(z_params& zs, boost::optional flush, error_code& ec) { maybe_init(); - if(zs.next_out == 0 || (zs.next_in == 0 && zs.avail_in != 0) || + if(zs.next_in == nullptr && zs.avail_in != 0) + BOOST_THROW_EXCEPTION(std::invalid_argument{"invalid input"}); + + if(zs.next_out == nullptr || (status_ == FINISH_STATE && flush != Flush::finish)) { ec = error::stream_error; diff --git a/test/beast/zlib/deflate_stream.cpp b/test/beast/zlib/deflate_stream.cpp index bb05c469..905093ba 100644 --- a/test/beast/zlib/deflate_stream.cpp +++ b/test/beast/zlib/deflate_stream.cpp @@ -328,6 +328,17 @@ public: deflate_stream ds; ds.reset(compression::default_size, 15, -1, Strategy::normal); }); + except( + []() + { + deflate_stream ds; + ds.reset(); + z_params zp{}; + zp.avail_in = 1; + zp.next_in = nullptr; + error_code ec; + ds.write(zp, Flush::full, ec); + }); } void