Crash if I try to copy uncompressed filtering_istream to stringstream
I want to uncompress a file and write its content into a stringstream. 

This is the code I tried:

  
    string readGZipLog () {
     try {
          using namespace boost::iostreams;
          ifstream file(currentFile.c_str(), std::ios_base::in | std::ios_base::binary);
          boost::iostreams::filtering_istream in;
          in.push(gzip_decompressor());
          in.push(file);
          std::stringstream strstream;
          boost::iostreams::copy(in, strstream);
          return strstream.str();
     } catch (std::exception& e) {
          cout << e.what() << endl;
     }
    }

    void writeGZipLog (char* data) {
        try {
          using namespace boost::iostreams;
          std::ofstream file( currentFile.c_str(), std::ios_base::out |  std::ios_base::binary );
          boost::iostreams::filtering_ostream out;
          out.push( gzip_compressor() );
          out.push(file);
          std::stringstream strstream;
          strstream << data;
          boost::iostreams::copy( strstream, data );
        } catch (std::exception& e) {
          cout << e.what() << endl;
        }
     }

It compiles without any warnings (and of course errors) but the function `readGZipLog()` crashes while running:

    gzip error
    ./build: line 3: 22174 Segmentation fault      ./test

*`./build` is the script that compiles and starts the application `./test` automatically*

I checked the file: It contains something, but I can't ungzip it using `gunzip`. So I am not sure whether the compression worked properly and if this has something to do with the `gzip error` thrown by Boost.

Can you give me a hit where the error(s) is(/are)?

Thanks for your help!

Paul
Crash if I try to copy uncompressed filtering_istream to stringstream
===

I want to uncompress a file and write its content into a stringstream. 

This is the code I tried:

  
    string readGZipLog () {
     try {
          using namespace boost::iostreams;
          ifstream file(currentFile.c_str(), std::ios_base::in | std::ios_base::binary);
          boost::iostreams::filtering_istream in;
          in.push(gzip_decompressor());
          in.push(file);
          std::stringstream strstream;
          boost::iostreams::copy(in, strstream);
          return strstream.str();
     } catch (std::exception& e) {
          cout << e.what() << endl;
     }
    }

    void writeGZipLog (char* data) {
        try {
          using namespace boost::iostreams;
          std::ofstream file( currentFile.c_str(), std::ios_base::out |  std::ios_base::binary );
          boost::iostreams::filtering_ostream out;
          out.push( gzip_compressor() );
          out.push(file);
          std::stringstream strstream;
          strstream << data;
          boost::iostreams::copy( strstream, data );
        } catch (std::exception& e) {
          cout << e.what() << endl;
        }
     }

It compiles without any warnings (and of course errors) but the function `readGZipLog()` crashes while running:

    gzip error
    ./build: line 3: 22174 Segmentation fault      ./test

*`./build` is the script that compiles and starts the application `./test` automatically*

I checked the file: It contains something, but I can't ungzip it using `gunzip`. So I am not sure whether the compression worked properly and if this has something to do with the `gzip error` thrown by Boost.

Can you give me a hit where the error(s) is(/are)?

Thanks for your help!

Paul