fixed from PVS-Studio

V668 There is no sense in testing the 'p' pointer against null, as the memory was allocated using the 'new' operator. The exception will be generated in the case of memory allocation error. sndfile.cpp
pull/30/head
ip_gpu 9 years ago
parent 77938cd0be
commit 91eab2b5d2

@ -339,8 +339,13 @@ BOOL CSoundFile::Destroy()
MODCOMMAND *CSoundFile::AllocatePattern(UINT rows, UINT nchns) MODCOMMAND *CSoundFile::AllocatePattern(UINT rows, UINT nchns)
//------------------------------------------------------------ //------------------------------------------------------------
{ {
MODCOMMAND *p = new MODCOMMAND[rows*nchns]; try {
if (p) memset(p, 0, rows*nchns*sizeof(MODCOMMAND)); MODCOMMAND *p = new MODCOMMAND[rows*nchns];
memset(p, 0, rows*nchns*sizeof(MODCOMMAND));
}
catch (std::bad_alloc& ba) {
}
return p; return p;
} }
@ -1777,8 +1782,15 @@ BOOL CSoundFile::SetPatternName(UINT nPat, LPCSTR lpszName)
{ {
if (!lpszName[0]) return TRUE; if (!lpszName[0]) return TRUE;
UINT len = (nPat+1)*MAX_PATTERNNAME; UINT len = (nPat+1)*MAX_PATTERNNAME;
char *p = new char[len];
if (!p) return FALSE; char *p;
try {
p = new char[len];
}
catch (std::bad_alloc& ba) {
return FALSE;
}
memset(p, 0, len); memset(p, 0, len);
if (m_lpszPatternNames) if (m_lpszPatternNames)
{ {

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

Loading…
Cancel
Save