Merge pull request #6201 from iSevenDays/patch-6

Fix potential  memory leak in SimpleAudioEngine::preloadEffect
This commit is contained in:
James Chen 2014-04-10 09:37:12 +08:00
commit a2fcc79ad0
1 changed files with 4 additions and 3 deletions

View File

@ -462,7 +462,7 @@ void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
{
ALuint buffer = AL_NONE;
ALuint source = AL_NONE;
soundData *data = new soundData;
checkALError("preloadEffect:init");
OpenALFile file;
@ -472,7 +472,7 @@ void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
fprintf(stderr, "Cannot read file: '%s'\n", fullPath.data());
return;
}
bool success = false;
const std::vector<OpenALDecoder *> &decoders = OpenALDecoder::getDecoders();
for (size_t i = 0, n = decoders.size(); !success && i < n; ++i)
@ -489,7 +489,8 @@ void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
alSourcei(source, AL_BUFFER, buffer);
checkALError("preloadEffect:alSourcei");
soundData *data = new soundData;
data->isLooped = false;
data->buffer = buffer;
data->source = source;