summaryrefslogtreecommitdiff
path: root/src/serialization.cpp
diff options
context:
space:
mode:
authorgregorycu <gregory.currie@gmail.com>2016-01-04 18:02:12 +1100
committerparamat <mat.gregory@virginmedia.com>2016-01-09 02:28:35 +0000
commit9c77725653061baa9ae169a966205a4eb2f6c3fd (patch)
tree8bb716b8d5f807708ac60b03d586e6b3f7165b89 /src/serialization.cpp
parent386d190e0915a7ed270c313b4e9998f25d219e41 (diff)
downloadminetest-9c77725653061baa9ae169a966205a4eb2f6c3fd.tar.gz
minetest-9c77725653061baa9ae169a966205a4eb2f6c3fd.tar.bz2
minetest-9c77725653061baa9ae169a966205a4eb2f6c3fd.zip
Replace instance of readsome with read in decompressZlib Make decompressZlib more robust
Diffstat (limited to 'src/serialization.cpp')
-rw-r--r--src/serialization.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/serialization.cpp b/src/serialization.cpp
index c0fbe10e2..79f66fcae 100644
--- a/src/serialization.cpp
+++ b/src/serialization.cpp
@@ -133,7 +133,8 @@ void decompressZlib(std::istream &is, std::ostream &os)
if(z.avail_in == 0)
{
z.next_in = (Bytef*)input_buffer;
- input_buffer_len = is.readsome(input_buffer, bufsize);
+ is.read(input_buffer, bufsize);
+ input_buffer_len = is.gcount();
z.avail_in = input_buffer_len;
//dstream<<"read fail="<<is.fail()<<" bad="<<is.bad()<<std::endl;
}
@@ -166,6 +167,7 @@ void decompressZlib(std::istream &is, std::ostream &os)
//dstream<<"z.avail_in="<<z.avail_in<<std::endl;
//dstream<<"fail="<<is.fail()<<" bad="<<is.bad()<<std::endl;
// Unget all the data that inflate didn't take
+ is.clear(); // Just in case EOF is set
for(u32 i=0; i < z.avail_in; i++)
{
is.unget();