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
This commit is contained in:
Vadim Zeitlin 2014-02-22 22:40:00 +00:00
parent 663bbf892b
commit 25a03f93a5

View File

@ -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;