fixed a double free bug in SetBufferIO(size_t) (coverity checker CID 62)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37875 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2006-03-07 23:04:10 +00:00
parent 66619ee50c
commit 0d2ef7a802

View File

@ -117,7 +117,10 @@ wxStreamBuffer::wxStreamBuffer(const wxStreamBuffer& buffer)
void wxStreamBuffer::FreeBuffer()
{
if ( m_destroybuf )
{
free(m_buffer_start);
m_buffer_start = NULL;
}
}
wxStreamBuffer::~wxStreamBuffer()
@ -163,15 +166,15 @@ void wxStreamBuffer::SetBufferIO(void *start,
void wxStreamBuffer::SetBufferIO(size_t bufsize)
{
// start by freeing the old buffer
FreeBuffer();
if ( bufsize )
{
// this will free the old buffer and allocate the new one
SetBufferIO(malloc(bufsize), bufsize, true /* take ownership */);
}
else // no buffer size => no buffer
{
// still free the old one
FreeBuffer();
InitBuffer();
}
}