Allow passing NULL buffer to wx{,F}File::{Read,Write} when count==0.

If the count of bytes to read or write is 0, the buffer pointer value
shouldn't matter as it's not used at all anyhow, so relax the assert and allow
it to be NULL in this case.

Closes #16018.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76030 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-02-27 15:46:36 +00:00
parent d5216a4afc
commit ae4b084e77
2 changed files with 12 additions and 0 deletions

View File

@@ -325,6 +325,9 @@ bool wxFile::ReadAll(wxString *str, const wxMBConv& conv)
// read
ssize_t wxFile::Read(void *pBuf, size_t nCount)
{
if ( !nCount )
return 0;
wxCHECK( (pBuf != NULL) && IsOpened(), 0 );
ssize_t iRc = wxRead(m_fd, pBuf, nCount);
@@ -341,6 +344,9 @@ ssize_t wxFile::Read(void *pBuf, size_t nCount)
// write
size_t wxFile::Write(const void *pBuf, size_t nCount)
{
if ( !nCount )
return 0;
wxCHECK( (pBuf != NULL) && IsOpened(), 0 );
ssize_t iRc = wxWrite(m_fd, pBuf, nCount);