aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorDavid Turner2010-10-15 13:11:34 +0000
committerDavid Turner2010-10-15 13:11:34 +0000
commit04973e85be84db4ac5a71a7012eb68c8e52af3c4 (patch)
tree5bd20e04d146c6a1cbc63bac2e92f29bad801995 /graphics
parente74e4814e43724eb9dc5b1cdece8958a03257135 (diff)
downloadscummvm-rg350-04973e85be84db4ac5a71a7012eb68c8e52af3c4.tar.gz
scummvm-rg350-04973e85be84db4ac5a71a7012eb68c8e52af3c4.tar.bz2
scummvm-rg350-04973e85be84db4ac5a71a7012eb68c8e52af3c4.zip
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. svn-id: r53489
Diffstat (limited to 'graphics')
-rw-r--r--graphics/video/codecs/qdm2.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/graphics/video/codecs/qdm2.cpp b/graphics/video/codecs/qdm2.cpp
index 0050b256d1..26b18b189b 100644
--- a/graphics/video/codecs/qdm2.cpp
+++ b/graphics/video/codecs/qdm2.cpp
@@ -1350,15 +1350,20 @@ static int getVlc2(GetBitContext *s, int16 (*table)[2], int bits, int maxDepth)
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_fft_tone_synthesizer(uint8 sub_packet) {
}
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 @@ void QDM2Stream::qdm2_calculate_fft(int channel) {
// 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];
}
/**