mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 02:09:17 +02:00
fixed some potential memory leaks and other errors detected by cppcheck
This commit is contained in:
16
Sound.cpp
16
Sound.cpp
@@ -56,8 +56,8 @@ TSoundContainer::TSoundContainer(LPDIRECTSOUND pDS, const char *Directory, const
|
||||
if (FAILED(pWaveSoundRead->Open(strdup(strFileName))))
|
||||
{
|
||||
// SetFileUI( hDlg, TEXT("Bad wave file.") );
|
||||
return;
|
||||
ErrorLog( "Missed sound: " + std::string(strFileName) );
|
||||
ErrorLog( "Missed sound: " + std::string( strFileName ) );
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(Name, ToLower(strFileName).c_str());
|
||||
@@ -108,16 +108,20 @@ TSoundContainer::TSoundContainer(LPDIRECTSOUND pDS, const char *Directory, const
|
||||
return; // E_OUTOFMEMORY;
|
||||
|
||||
// if (FAILED(hr=pWaveSoundRead->Read( nWaveFileSize,pbWavData,&cbWavSize)))
|
||||
if (FAILED(hr = pWaveSoundRead->Read(nWaveFileSize, pbWavData, &cbWavSize)))
|
||||
return;
|
||||
if( FAILED( hr = pWaveSoundRead->Read( nWaveFileSize, pbWavData, &cbWavSize ) ) ) {
|
||||
delete[] pbWavData;
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset the file to the beginning
|
||||
pWaveSoundRead->Reset();
|
||||
|
||||
// Lock the buffer down
|
||||
// if (FAILED(hr=DSBuffer->Lock(0,dwBufferBytes,&pbData,&dwLength,&pbData2,&dwLength2,0)))
|
||||
if (FAILED(hr = DSBuffer->Lock(0, dwBufferBytes, &pbData, &dwLength, &pbData2, &dwLength2, 0L)))
|
||||
return;
|
||||
if( FAILED( hr = DSBuffer->Lock( 0, dwBufferBytes, &pbData, &dwLength, &pbData2, &dwLength2, 0L ) ) ) {
|
||||
delete[] pbWavData;
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy the memory to it.
|
||||
memcpy(pbData, pbWavData, dwBufferBytes);
|
||||
|
||||
Reference in New Issue
Block a user