ref: 9f3c31d25eb3a94eb25aa9a6345a7dfa7b939dbc
parent: 44e7816658ea0f995343ee7bb288001b3647925b
author: menno <menno>
date: Thu Dec 5 13:01:57 EST 2002
Better bit error handling
--- a/libfaad/decoder.c
+++ b/libfaad/decoder.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: decoder.c,v 1.41 2002/12/02 20:27:51 menno Exp $
+** $Id: decoder.c,v 1.42 2002/12/05 18:01:49 menno Exp $
**/
#include "common.h"
@@ -634,13 +634,13 @@
/* cleanup */
for (ch = 0; ch < channels; ch++)
{
- free(spec_coef[ch]);
- free(spec_data[ch]);
+ if (spec_coef[ch]) free(spec_coef[ch]);
+ if (spec_data[ch]) free(spec_data[ch]);
}
for (i = 0; i < ch_ele; i++)
{
- free(syntax_elements[i]);
+ if (syntax_elements[i]) free(syntax_elements[i]);
}
#ifdef ANALYSIS
--- a/libfaad/error.c
+++ b/libfaad/error.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: error.c,v 1.6 2002/08/27 10:24:55 menno Exp $
+** $Id: error.c,v 1.7 2002/12/05 18:01:55 menno Exp $
**/
#include "common.h"
@@ -34,5 +34,7 @@
"Bit error in error resilient scalefactor decoding",
"Error decoding huffman scalefactor (bitstream error)",
"Error decoding huffman codeword (bitstream error)",
- "Non existent huffman codebook number found"
+ "Non existent huffman codebook number found",
+ "Maximum number of channels exceeded",
+ "Maximum number of bitstream elements exceeded"
};
\ No newline at end of file
--- a/libfaad/syntax.c
+++ b/libfaad/syntax.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: syntax.c,v 1.32 2002/11/28 18:48:30 menno Exp $
+** $Id: syntax.c,v 1.33 2002/12/05 18:01:57 menno Exp $
**/
/*
@@ -285,6 +285,29 @@
return ele;
}
+#define CHCHECK1 \
+ if (channels+1 >= MAX_CHANNELS) \
+ { \
+ hInfo->error = 12; \
+ goto return_on_error; \
+ } \
+ if (ch_ele+1 >= MAX_SYNTAX_ELEMENTS) \
+ { \
+ hInfo->error = 13; \
+ goto return_on_error; \
+ }
+#define CHCHECK2 \
+ if (channels+2 >= MAX_CHANNELS) \
+ { \
+ hInfo->error = 12; \
+ goto return_on_error; \
+ } \
+ if (ch_ele+1 >= MAX_SYNTAX_ELEMENTS) \
+ { \
+ hInfo->error = 13; \
+ goto return_on_error; \
+ }
+
element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
bitfile *ld, element **elements,
int16_t **spec_data, real_t **spec_coef,
@@ -307,6 +330,7 @@
switch (id_syn_ele) {
case ID_SCE:
case ID_LFE:
+ CHCHECK1;
elements[ch_ele] = decode_sce_lfe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
ch_ele++; channels++;
@@ -314,6 +338,7 @@
goto return_on_error;
break;
case ID_CPE:
+ CHCHECK2;
elements[ch_ele] = decode_cpe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
channels += 2; ch_ele++;
@@ -344,6 +369,7 @@
{
case 1:
id_syn_ele = ID_SCE;
+ CHCHECK1;
elements[ch_ele] = decode_sce_lfe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
ch_ele++; channels++;
@@ -352,6 +378,7 @@
break;
case 2:
id_syn_ele = ID_CPE;
+ CHCHECK2;
elements[ch_ele] = decode_cpe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
channels += 2; ch_ele++;
@@ -360,6 +387,7 @@
break;
case 3:
id_syn_ele = ID_SCE;
+ CHCHECK1;
elements[ch_ele] = decode_sce_lfe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
ch_ele++; channels++;
@@ -366,6 +394,7 @@
if (hInfo->error > 0)
goto return_on_error;
id_syn_ele = ID_CPE;
+ CHCHECK2;
elements[ch_ele] = decode_cpe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
channels += 2; ch_ele++;
@@ -374,6 +403,7 @@
break;
case 4:
id_syn_ele = ID_SCE;
+ CHCHECK1;
elements[ch_ele] = decode_sce_lfe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
ch_ele++; channels++;
@@ -380,6 +410,7 @@
if (hInfo->error > 0)
goto return_on_error;
id_syn_ele = ID_CPE;
+ CHCHECK2;
elements[ch_ele] = decode_cpe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
channels += 2; ch_ele++;
@@ -386,6 +417,7 @@
if (hInfo->error > 0)
goto return_on_error;
id_syn_ele = ID_SCE;
+ CHCHECK1;
elements[ch_ele] = decode_sce_lfe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
ch_ele++; channels++;
@@ -394,6 +426,7 @@
break;
case 5:
id_syn_ele = ID_SCE;
+ CHCHECK1;
elements[ch_ele] = decode_sce_lfe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
ch_ele++; channels++;
@@ -400,6 +433,7 @@
if (hInfo->error > 0)
goto return_on_error;
id_syn_ele = ID_CPE;
+ CHCHECK2;
elements[ch_ele] = decode_cpe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
channels += 2; ch_ele++;
@@ -406,6 +440,7 @@
if (hInfo->error > 0)
goto return_on_error;
id_syn_ele = ID_CPE;
+ CHCHECK2;
elements[ch_ele] = decode_cpe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
channels += 2; ch_ele++;
@@ -414,6 +449,7 @@
break;
case 6:
id_syn_ele = ID_SCE;
+ CHCHECK1;
elements[ch_ele] = decode_sce_lfe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
ch_ele++; channels++;
@@ -420,6 +456,7 @@
if (hInfo->error > 0)
goto return_on_error;
id_syn_ele = ID_CPE;
+ CHCHECK2;
elements[ch_ele] = decode_cpe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
channels += 2; ch_ele++;
@@ -426,6 +463,7 @@
if (hInfo->error > 0)
goto return_on_error;
id_syn_ele = ID_CPE;
+ CHCHECK2;
elements[ch_ele] = decode_cpe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
channels += 2; ch_ele++;
@@ -432,6 +470,7 @@
if (hInfo->error > 0)
goto return_on_error;
id_syn_ele = ID_LFE;
+ CHCHECK1;
elements[ch_ele] = decode_sce_lfe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
ch_ele++; channels++;
@@ -440,6 +479,7 @@
break;
case 7:
id_syn_ele = ID_SCE;
+ CHCHECK1;
elements[ch_ele] = decode_sce_lfe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
ch_ele++; channels++;
@@ -446,6 +486,7 @@
if (hInfo->error > 0)
goto return_on_error;
id_syn_ele = ID_CPE;
+ CHCHECK2;
elements[ch_ele] = decode_cpe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
channels += 2; ch_ele++;
@@ -452,6 +493,7 @@
if (hInfo->error > 0)
goto return_on_error;
id_syn_ele = ID_CPE;
+ CHCHECK2;
elements[ch_ele] = decode_cpe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
channels += 2; ch_ele++;
@@ -458,6 +500,7 @@
if (hInfo->error > 0)
goto return_on_error;
id_syn_ele = ID_CPE;
+ CHCHECK2;
elements[ch_ele] = decode_cpe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
channels += 2; ch_ele++;
@@ -464,6 +507,7 @@
if (hInfo->error > 0)
goto return_on_error;
id_syn_ele = ID_LFE;
+ CHCHECK1;
elements[ch_ele] = decode_sce_lfe(hDecoder,
hInfo, ld, spec_data, spec_coef, channels, id_syn_ele);
ch_ele++; channels++;