From 0928bca531938db3f9ea795530dfef21665c5c98 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sat, 10 Nov 2012 10:12:01 +0100 Subject: [PATCH] Proper fix for gzfilebuf choking on some files. When reading a new block of data, and the first byte of the new block is 0xff (_signed_ char -1), then this must be converted to _integer_ 0xff (+255), not -1 - which would indicate an error condition (EOF==-1). All valid _data_ character must be returned as non-negative, see streambuf::underflow spec, or compare with http://www.opensource.apple.com/source/zlib/zlib-12/zlib/contrib/iostream/zfstream.cpp or http://www.raspberryginger.com/jbailey/minix/html/zfstream_8cpp-source.html --- simgear/misc/zfstream.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simgear/misc/zfstream.cxx b/simgear/misc/zfstream.cxx index 38a16ff2..eae24f78 100644 --- a/simgear/misc/zfstream.cxx +++ b/simgear/misc/zfstream.cxx @@ -270,7 +270,7 @@ gzfilebuf::underflow() } else { - return fillbuf() == EOF ? traits_type::eof() : int_type(*gptr()); + return fillbuf() == EOF ? traits_type::eof() : (unsigned char) (*gptr()); } } -- 2.39.5