diff options
| author | ljfa-ag <ljfa-ag@web.de> | 2015-09-15 11:34:44 +0200 |
|---|---|---|
| committer | ljfa-ag <ljfa-ag@web.de> | 2015-09-15 12:04:08 +0200 |
| commit | a692b3be10084aec02a5b6483c878e1dc20081f2 (patch) | |
| tree | aae909881dde16ad11d14e2758dfe487f418c2f2 /src | |
| parent | 089a804a12c0592b0d2a396df1d35dad4fd134c0 (diff) | |
| download | Project-Tick-a692b3be10084aec02a5b6483c878e1dc20081f2.tar.gz Project-Tick-a692b3be10084aec02a5b6483c878e1dc20081f2.zip | |
Check for errors in input stream
Diffstat (limited to 'src')
| -rw-r--r-- | src/io/izlibstream.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/io/izlibstream.cpp b/src/io/izlibstream.cpp index f9d9463d95..db69e0e626 100644 --- a/src/io/izlibstream.cpp +++ b/src/io/izlibstream.cpp @@ -24,7 +24,7 @@ namespace zlib { inflate_streambuf::inflate_streambuf(std::istream& input, size_t bufsize, int window_bits): - is(input), in(bufsize), out(bufsize) + is(input), in(bufsize), out(bufsize), stream_end(false) { zstr.zalloc = Z_NULL; zstr.zfree = Z_NULL; @@ -56,7 +56,12 @@ inflate_streambuf::int_type inflate_streambuf::underflow() if(zstr.avail_in <= 0) { is.read(in.data(), in.size()); + if(is.bad()) + throw std::ios_base::failure("Input stream is bad"); size_t count = is.gcount(); + if(count == 0 && !stream_end) + throw zlib_error("Unexpected end of stream", Z_DATA_ERROR); + zstr.next_in = reinterpret_cast<Bytef*>(in.data()); zstr.avail_in = count; } @@ -76,6 +81,7 @@ inflate_streambuf::int_type inflate_streambuf::underflow() throw std::bad_alloc(); case Z_STREAM_END: + stream_end = true; if(have == 0) return traits_type::eof(); break; |
