From 25a03f93a5654d3506061e631f193464ca05ae9b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 22 Feb 2014 22:40:00 +0000 Subject: [PATCH] Improve parameter validation in wxStream code. Replace wxASSERT_MSG()s with wxCHECK_MSG()s to ensure that we don't crash even if we are passed a NULL pointer, saying "Warning: Null pointer is about to be used" and crashing just isn't very useful in the grand scheme of things. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75989 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/stream.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/stream.cpp b/src/common/stream.cpp index fd50f8beac..1745a871ed 100644 --- a/src/common/stream.cpp +++ b/src/common/stream.cpp @@ -390,7 +390,7 @@ char wxStreamBuffer::GetChar() size_t wxStreamBuffer::Read(void *buffer, size_t size) { - wxASSERT_MSG( buffer, wxT("Warning: Null pointer is about to be used") ); + wxCHECK_MSG( buffer, 0, wxT("NULL data pointer") ); /* Clear buffer first */ memset(buffer, 0x00, size); @@ -471,7 +471,7 @@ size_t wxStreamBuffer::Read(wxStreamBuffer *dbuf) size_t wxStreamBuffer::Write(const void *buffer, size_t size) { - wxASSERT_MSG( buffer, wxT("Warning: Null pointer is about to be send") ); + wxCHECK_MSG( buffer, 0, wxT("NULL data pointer") ); if (m_stream) { @@ -771,7 +771,7 @@ char *wxInputStream::AllocSpaceWBack(size_t needed_size) size_t wxInputStream::GetWBack(void *buf, size_t size) { - wxASSERT_MSG( buf, wxT("Warning: Null pointer is about to be used") ); + wxCHECK_MSG( buf, 0, wxT("NULL data pointer") ); /* Clear buffer first */ memset(buf, 0x00, size); @@ -807,7 +807,7 @@ size_t wxInputStream::GetWBack(void *buf, size_t size) size_t wxInputStream::Ungetch(const void *buf, size_t bufsize) { - wxASSERT_MSG( buf, wxT("Warning: Null pointer is about to be used in Ungetch()") ); + wxCHECK_MSG( buf, 0, wxT("NULL data pointer") ); if ( m_lasterror != wxSTREAM_NO_ERROR && m_lasterror != wxSTREAM_EOF ) { @@ -841,7 +841,7 @@ int wxInputStream::GetC() wxInputStream& wxInputStream::Read(void *buf, size_t size) { - wxASSERT_MSG( buf, wxT("Warning: Null pointer is about to be read") ); + wxCHECK_MSG( buf, *this, wxT("NULL data pointer") ); char *p = (char *)buf; m_lastcount = 0;