From 7eae2e17c207eb8b37f80e4ee2d7ccba2d28be0d Mon Sep 17 00:00:00 2001 From: Mike Melanson Date: Tue, 3 Sep 2002 02:46:30 +0000 Subject: fix SMJPEG IMA so that it does not crash due to NULL pointer dereference (but the audio still crackles) CVS patchset: 2593 CVS date: 2002/09/03 02:46:30 --- src/libxineadec/adpcm.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/libxineadec/adpcm.c b/src/libxineadec/adpcm.c index 46ac42162..a4382157f 100644 --- a/src/libxineadec/adpcm.c +++ b/src/libxineadec/adpcm.c @@ -24,7 +24,7 @@ * formats can be found here: * http://www.pcisys.net/~melanson/codecs/ * - * $Id: adpcm.c,v 1.11 2002/09/02 17:25:45 tmmm Exp $ + * $Id: adpcm.c,v 1.12 2002/09/03 02:46:30 tmmm Exp $ */ #include @@ -156,12 +156,17 @@ static void decode_ima_nibbles(unsigned short *output, int delta; int channel_number = 0; + /* take care of the left */ step[0] = ima_adpcm_step[*index_l]; - step[1] = ima_adpcm_step[*index_r]; predictor[0] = *predictor_l; - predictor[1] = *predictor_r; index[0] = *index_l; - index[1] = *index_r; + + /* only handle the right if non-NULL pointers */ + if (index_r) { + step[1] = ima_adpcm_step[*index_r]; + predictor[1] = *predictor_r; + index[1] = *index_r; + } for (i = 0; i < output_size; i++) { delta = output[i]; @@ -192,9 +197,13 @@ static void decode_ima_nibbles(unsigned short *output, /* save the index and predictor values in case the calling function cares */ *predictor_l = predictor[0]; - *predictor_r = predictor[1]; *index_l = index[0]; - *index_r = index[1]; + + /* only save the right channel information if pointers are non-NULL */ + if (predictor_r) { + *predictor_r = predictor[1]; + *index_r = index[1]; + } } #define DK3_GET_NEXT_NIBBLE() \ -- cgit v1.2.3