[MPlayer-dev-eng] [PATCH] Fix segfault in libmpcodecs/ad_imaadpcm.c

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun May 10 11:15:24 CEST 2009


On Sun, May 10, 2009 at 02:44:00AM +0100, Craig Shelley wrote:
> Index: libmpcodecs/ad_imaadpcm.c
> ===================================================================
> --- libmpcodecs/ad_imaadpcm.c	(revision 29285)
> +++ libmpcodecs/ad_imaadpcm.c	(working copy)
> @@ -133,8 +133,10 @@
>    int delta;
>    int channel_number = 0;
>  
> -  step[0] = adpcm_step[index[0]];
> -  step[1] = adpcm_step[index[1]];
> +  for (i = 0; i < channels && i < 2; i++)
> +  {
> +    step[i] = adpcm_step[index[i]];
> +  }

Just putting the step[1] under an if would be simpler, but I think this
would be preferable:
Index: ad_imaadpcm.c
===================================================================
--- ad_imaadpcm.c       (revision 29271)
+++ ad_imaadpcm.c       (working copy)
@@ -163,8 +163,8 @@
 static int qt_ima_adpcm_decode_block(unsigned short *output,
   unsigned char *input, int channels, int block_size)
 {
-  int initial_predictor[2];
-  int initial_index[2];
+  int initial_predictor[2] = {0};
+  int initial_index[2] = {0};
   int i;
 
   if (channels != 1) channels = 2;



Independent of this, isn't the libavcodec imaadpcm decoder the default
nowadays? I haven't completely checked it yet, but it might be better in
the long term to just remove this code.



More information about the MPlayer-dev-eng mailing list