Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62962 - in trunk/libs/iostreams: src test
From: steven_at_[hidden]
Date: 2010-06-14 21:22:52


Author: steven_watanabe
Date: 2010-06-14 21:22:50 EDT (Mon, 14 Jun 2010)
New Revision: 62962
URL: http://svn.boost.org/trac/boost/changeset/62962

Log:
Make sure that the bzip2 filters can be closed even if no input has been read. Fixes #3348.
Text files modified:
   trunk/libs/iostreams/src/bzip2.cpp | 1 +
   trunk/libs/iostreams/test/bzip2_test.cpp | 11 +++++++++++
   trunk/libs/iostreams/test/zlib_test.cpp | 16 ++++++++++++++++
   3 files changed, 28 insertions(+), 0 deletions(-)

Modified: trunk/libs/iostreams/src/bzip2.cpp
==============================================================================
--- trunk/libs/iostreams/src/bzip2.cpp (original)
+++ trunk/libs/iostreams/src/bzip2.cpp 2010-06-14 21:22:50 EDT (Mon, 14 Jun 2010)
@@ -101,6 +101,7 @@
 
 void bzip2_base::end(bool compress)
 {
+ if(!ready_) return;
     ready_ = false;
     bz_stream* s = static_cast<bz_stream*>(stream_);
     bzip2_error::check BOOST_PREVENT_MACRO_SUBSTITUTION(

Modified: trunk/libs/iostreams/test/bzip2_test.cpp
==============================================================================
--- trunk/libs/iostreams/test/bzip2_test.cpp (original)
+++ trunk/libs/iostreams/test/bzip2_test.cpp 2010-06-14 21:22:50 EDT (Mon, 14 Jun 2010)
@@ -8,6 +8,7 @@
 #include <string>
 #include <boost/iostreams/filter/bzip2.hpp>
 #include <boost/iostreams/filter/test.hpp>
+#include <boost/iostreams/filtering_stream.hpp>
 #include <boost/test/test_tools.hpp>
 #include <boost/test/unit_test.hpp>
 #include "detail/sequence.hpp"
@@ -38,6 +39,16 @@
                           bzip2_decompressor(),
                           std::string() )
     );
+ {
+ filtering_istream strm;
+ strm.push( bzip2_compressor() );
+ strm.push( null_source() );
+ }
+ {
+ filtering_istream strm;
+ strm.push( bzip2_decompressor() );
+ strm.push( null_source() );
+ }
 }
 
 test_suite* init_unit_test_suite(int, char* [])

Modified: trunk/libs/iostreams/test/zlib_test.cpp
==============================================================================
--- trunk/libs/iostreams/test/zlib_test.cpp (original)
+++ trunk/libs/iostreams/test/zlib_test.cpp 2010-06-14 21:22:50 EDT (Mon, 14 Jun 2010)
@@ -8,6 +8,7 @@
 #include <string>
 #include <boost/iostreams/filter/test.hpp>
 #include <boost/iostreams/filter/zlib.hpp>
+#include <boost/iostreams/filtering_stream.hpp>
 #include <boost/test/test_tools.hpp>
 #include <boost/test/unit_test.hpp>
 #include "detail/sequence.hpp"
@@ -34,6 +35,21 @@
                           basic_zlib_decompressor<zlib_alloc>(),
                           std::string(data.begin(), data.end()) )
     );
+ BOOST_CHECK(
+ test_filter_pair( zlib_compressor(),
+ zlib_decompressor(),
+ std::string() )
+ );
+ {
+ filtering_istream strm;
+ strm.push( zlib_compressor() );
+ strm.push( null_source() );
+ }
+ {
+ filtering_istream strm;
+ strm.push( zlib_decompressor() );
+ strm.push( null_source() );
+ }
 }
 
 test_suite* init_unit_test_suite(int, char* [])


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk