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:
parent
66619ee50c
commit
0d2ef7a802
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user