fixed from PVS-Studio

V668 There is no sense in testing the 'm_lpszSongComments' pointer against null, as the memory was allocated using the 'new' operator. The exception will be generated in the case of memory allocation error. load_mtm.cpp 143
pull/26/head
ip_gpu 9 years ago
parent 77938cd0be
commit 111bb3e08c

@ -139,19 +139,21 @@ BOOL CSoundFile::ReadMTM(LPCBYTE lpStream, DWORD dwMemLength)
if ((pmh->commentsize) && (dwMemPos + pmh->commentsize < dwMemLength))
{
UINT n = pmh->commentsize;
m_lpszSongComments = new char[n+1];
if (m_lpszSongComments)
{
memcpy(m_lpszSongComments, lpStream+dwMemPos, n);
try {
m_lpszSongComments = new char[n + 1];
memcpy(m_lpszSongComments, lpStream + dwMemPos, n);
m_lpszSongComments[n] = 0;
for (UINT i=0; i<n; i++)
for (UINT i = 0; i < n; i++)
{
if (!m_lpszSongComments[i])
{
m_lpszSongComments[i] = ((i+1) % 40) ? 0x20 : 0x0D;
m_lpszSongComments[i] = ((i + 1) % 40) ? 0x20 : 0x0D;
}
}
}
catch (std::bad_alloc& ba) {
}
}
dwMemPos += pmh->commentsize;
// Reading Samples

@ -13,6 +13,8 @@
#ifndef __SNDFILE_H
#define __SNDFILE_H
#include <new>
#ifdef UNDER_CE
int _strnicmp(const char *str1,const char *str2, int n);
#endif

Loading…
Cancel
Save