From: Paweł Sikora Date: Mon, 30 Jun 2008 10:03:24 +0000 (+0000) Subject: - bug (infinite loop) fix. X-Git-Tag: auto/th/STLport-5_1_5-8~1 X-Git-Url: http://git.pld-linux.org/gitweb.cgi?p=packages%2FSTLport.git;a=commitdiff_plain;h=2bfba1ab36d738546e903b884b6862d7ae516a3f - bug (infinite loop) fix. Changed files: STLport-fstream.patch -> 1.1 --- diff --git a/STLport-fstream.patch b/STLport-fstream.patch new file mode 100644 index 0000000..577cbf9 --- /dev/null +++ b/STLport-fstream.patch @@ -0,0 +1,31 @@ +this patch fixes inifinite loop in following testcase: + +#include +#include +#include +int main() +{ + std::ifstream in( "/tmp" ); + assert( in.good() ); + std::string buf; + std::getline( in, buf ); + assert( in.fail() ); +} + +Index: STLport-trunk/stlport/stl/_fstream.c +=================================================================== +--- STLport-trunk/stlport/stl/_fstream.c (wersja 3579) ++++ STLport-trunk/stlport/stl/_fstream.c (wersja 3580) +@@ -513,6 +513,12 @@ + // to make progress. + for (;;) { + ptrdiff_t __n = _M_base._M_read(_M_ext_buf_end, _M_ext_buf_EOS - _M_ext_buf_end); ++ if (__n < 0) { ++ // Read failed, maybe we should set err bit on associated stream... ++ this->setg(0, 0, 0); ++ return traits_type::eof(); ++ } ++ + _M_ext_buf_end += __n; + + // If external buffer is empty there is nothing to do.