diff options
author | fritsch <Peter.Fruehberger@gmail.com> | 2014-12-22 12:43:15 +0100 |
---|---|---|
committer | fritsch <Peter.Fruehberger@gmail.com> | 2014-12-22 14:15:21 +0100 |
commit | 811d6936163c8ddfde64576d60cf24ba0d31a55c (patch) | |
tree | d1d81a7ac93a38e66b96efc50c7452dcb1f9de5f | |
parent | 33c4063cc27695292491d2447d629182484ac653 (diff) |
CFile: Don't cast potential negative values to unsigned int
-rw-r--r-- | xbmc/filesystem/File.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/xbmc/filesystem/File.cpp b/xbmc/filesystem/File.cpp index c25667d320..5156284542 100644 --- a/xbmc/filesystem/File.cpp +++ b/xbmc/filesystem/File.cpp @@ -1034,10 +1034,15 @@ CFileStreamBuffer::int_type CFileStreamBuffer::underflow() memmove(m_buffer, egptr()-backsize, backsize); } - unsigned int size = m_file->Read(m_buffer+backsize, m_frontsize); + ssize_t size = m_file->Read(m_buffer+backsize, m_frontsize); - if(size == 0) + if (size == 0) return traits_type::eof(); + else if (size < 0) + { + CLog::LogF(LOGWARNING, "Error reading file - assuming eof"); + return traits_type::eof(); + } setg(m_buffer, m_buffer+backsize, m_buffer+backsize+size); return traits_type::to_int_type(*gptr()); |