Fix last count value after ReadAll() and WriteAll().
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
This commit is contained in:
@@ -917,7 +917,7 @@ bool wxInputStream::ReadAll(void *buffer_, size_t size)
|
|||||||
{
|
{
|
||||||
char* buffer = static_cast<char*>(buffer_);
|
char* buffer = static_cast<char*>(buffer_);
|
||||||
|
|
||||||
m_lastcount = 0;
|
size_t totalCount = 0;
|
||||||
|
|
||||||
for ( ;; )
|
for ( ;; )
|
||||||
{
|
{
|
||||||
@@ -928,7 +928,7 @@ bool wxInputStream::ReadAll(void *buffer_, size_t size)
|
|||||||
if ( !lastCount )
|
if ( !lastCount )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
m_lastcount += lastCount;
|
totalCount += lastCount;
|
||||||
|
|
||||||
// ... Or if an error occurred on the stream.
|
// ... Or if an error occurred on the stream.
|
||||||
if ( !IsOk() )
|
if ( !IsOk() )
|
||||||
@@ -939,14 +939,19 @@ bool wxInputStream::ReadAll(void *buffer_, size_t size)
|
|||||||
// "==" test, but be safe and avoid overflowing size even in case of
|
// "==" test, but be safe and avoid overflowing size even in case of
|
||||||
// bugs in LastRead()).
|
// bugs in LastRead()).
|
||||||
if ( lastCount >= size )
|
if ( lastCount >= size )
|
||||||
return true;
|
{
|
||||||
|
size = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Advance the buffer before trying to read the rest of data.
|
// Advance the buffer before trying to read the rest of data.
|
||||||
size -= lastCount;
|
size -= lastCount;
|
||||||
buffer += lastCount;
|
buffer += lastCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
m_lastcount = totalCount;
|
||||||
|
|
||||||
|
return size == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFileOffset wxInputStream::SeekI(wxFileOffset pos, wxSeekMode mode)
|
wxFileOffset wxInputStream::SeekI(wxFileOffset pos, wxSeekMode mode)
|
||||||
@@ -1071,7 +1076,7 @@ bool wxOutputStream::WriteAll(const void *buffer_, size_t size)
|
|||||||
// This exactly mirrors ReadAll(), see there for more comments.
|
// This exactly mirrors ReadAll(), see there for more comments.
|
||||||
const char* buffer = static_cast<const char*>(buffer_);
|
const char* buffer = static_cast<const char*>(buffer_);
|
||||||
|
|
||||||
m_lastcount = 0;
|
size_t totalCount = 0;
|
||||||
|
|
||||||
for ( ;; )
|
for ( ;; )
|
||||||
{
|
{
|
||||||
@@ -1079,19 +1084,23 @@ bool wxOutputStream::WriteAll(const void *buffer_, size_t size)
|
|||||||
if ( !lastCount )
|
if ( !lastCount )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
m_lastcount += lastCount;
|
totalCount += lastCount;
|
||||||
|
|
||||||
if ( !IsOk() )
|
if ( !IsOk() )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ( lastCount >= size )
|
if ( lastCount >= size )
|
||||||
return true;
|
{
|
||||||
|
size = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
size -= lastCount;
|
size -= lastCount;
|
||||||
buffer += lastCount;
|
buffer += lastCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
m_lastcount = totalCount;
|
||||||
|
return size == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFileOffset wxOutputStream::TellO() const
|
wxFileOffset wxOutputStream::TellO() const
|
||||||
|
Reference in New Issue
Block a user