[Scummvm-cvs-logs] SF.net SVN: scummvm:[53489] scummvm/trunk/graphics/video/codecs/qdm2.cpp
tdhs at users.sourceforge.net
tdhs at users.sourceforge.net
Fri Oct 15 15:11:35 CEST 2010
Revision: 53489
http://scummvm.svn.sourceforge.net/scummvm/?rev=53489&view=rev
Author: tdhs
Date: 2010-10-15 13:11:34 +0000 (Fri, 15 Oct 2010)
Log Message:
-----------
VIDEO : Corrections to QDM2 codec for bug #3087917 "Code Analysis Warnings"
The first correction was to use a temporary variable to remove the possibility of a memory leak when using realloc.
The second correction was to remove the gain variable from QDM2Stream::qdm2_calculate_fft() which has always evaluated to 1.0f and so has no effect.
Modified Paths:
--------------
scummvm/trunk/graphics/video/codecs/qdm2.cpp
Modified: scummvm/trunk/graphics/video/codecs/qdm2.cpp
===================================================================
--- scummvm/trunk/graphics/video/codecs/qdm2.cpp 2010-10-15 13:07:31 UTC (rev 53488)
+++ scummvm/trunk/graphics/video/codecs/qdm2.cpp 2010-10-15 13:11:34 UTC (rev 53489)
@@ -1350,15 +1350,20 @@
static int allocTable(VLC *vlc, int size, int use_static) {
int index;
+ int16 (*temp)[2] = NULL;
index = vlc->table_size;
vlc->table_size += size;
if (vlc->table_size > vlc->table_allocated) {
if(use_static)
error("QDM2 cant do anything, init_vlc() is used with too little memory");
vlc->table_allocated += (1 << vlc->bits);
- vlc->table = (int16 (*)[2])realloc(vlc->table, sizeof(int16 *) * 2 * vlc->table_allocated);
- if (!vlc->table)
+ temp = (int16 (*)[2])realloc(vlc->table, sizeof(int16 *) * 2 * vlc->table_allocated);
+ if (!temp) {
+ free(vlc->table);
+ vlc->table = NULL;
return -1;
+ }
+ vlc->table = temp;
}
return index;
}
@@ -3112,7 +3117,6 @@
}
void QDM2Stream::qdm2_calculate_fft(int channel) {
- const float gain = (_channels == 1 && _channels == 2) ? 0.5f : 1.0f;
int i;
_fft.complex[channel][0].re *= 2.0f;
@@ -3122,7 +3126,7 @@
// add samples to output buffer
for (i = 0; i < ((_fftFrameSize + 15) & ~15); i++)
- _outputBuffer[_channels * i + channel] += ((float *) _fft.complex[channel])[i] * gain;
+ _outputBuffer[_channels * i + channel] += ((float *) _fft.complex[channel])[i];
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list