From 2bfba1ab36d738546e903b884b6862d7ae516a3f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Sikora?= Date: Mon, 30 Jun 2008 10:03:24 +0000 Subject: [PATCH] - bug (infinite loop) fix. Changed files: STLport-fstream.patch -> 1.1 --- STLport-fstream.patch | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 STLport-fstream.patch 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. -- 2.44.0