Fixed MemoryStream::Read crash when just skipping (null buffer)

Former-commit-id: 46072c0ebd093bcfa1e7f54d11deb034cbc55dae
This commit is contained in:
Lynix 2013-11-06 23:56:20 +01:00
parent f722d83955
commit c647b61904
1 changed files with 4 additions and 1 deletions

View File

@ -36,7 +36,10 @@ nzUInt64 NzMemoryStream::GetSize() const
std::size_t NzMemoryStream::Read(void* buffer, std::size_t size)
{
unsigned int readSize = std::min(static_cast<unsigned int>(size), static_cast<unsigned int>(m_size-m_pos));
std::memcpy(buffer, &m_ptr[m_pos], readSize);
if (buffer)
std::memcpy(buffer, &m_ptr[m_pos], readSize);
m_pos += readSize;
return readSize;