This corrects the bugs introduced when applying the patch adding these
functions in r74034: we can't simply use m_lastcount directly in them because
it's also modified by each call to Read() and Write(), so do use the temporary
variable.
See #12056.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74038
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
{
char* buffer = static_cast<char*>(buffer_);
{
char* buffer = static_cast<char*>(buffer_);
- m_lastcount += lastCount;
+ totalCount += lastCount;
// ... Or if an error occurred on the stream.
if ( !IsOk() )
// ... Or if an error occurred on the stream.
if ( !IsOk() )
// "==" test, but be safe and avoid overflowing size even in case of
// bugs in LastRead()).
if ( lastCount >= size )
// "==" test, but be safe and avoid overflowing size even in case of
// bugs in LastRead()).
if ( lastCount >= size )
+ {
+ size = 0;
+ break;
+ }
// Advance the buffer before trying to read the rest of data.
size -= lastCount;
buffer += lastCount;
}
// Advance the buffer before trying to read the rest of data.
size -= lastCount;
buffer += lastCount;
}
+ m_lastcount = totalCount;
+
+ return size == 0;
}
wxFileOffset wxInputStream::SeekI(wxFileOffset pos, wxSeekMode mode)
}
wxFileOffset wxInputStream::SeekI(wxFileOffset pos, wxSeekMode mode)
// This exactly mirrors ReadAll(), see there for more comments.
const char* buffer = static_cast<const char*>(buffer_);
// This exactly mirrors ReadAll(), see there for more comments.
const char* buffer = static_cast<const char*>(buffer_);
- m_lastcount += lastCount;
+ totalCount += lastCount;
if ( !IsOk() )
break;
if ( lastCount >= size )
if ( !IsOk() )
break;
if ( lastCount >= size )
+ {
+ size = 0;
+ break;
+ }
size -= lastCount;
buffer += lastCount;
}
size -= lastCount;
buffer += lastCount;
}
+ m_lastcount = totalCount;
+ return size == 0;
}
wxFileOffset wxOutputStream::TellO() const
}
wxFileOffset wxOutputStream::TellO() const