]> git.sesse.net Git - vlc/commitdiff
mpeg4audio: Fix a crash with some invalid streams.
authorHugo Beauzée-Luyssen <beauze.h@gmail.com>
Tue, 17 Apr 2012 12:29:35 +0000 (14:29 +0200)
committerHugo Beauzée-Luyssen <beauze.h@gmail.com>
Tue, 17 Apr 2012 12:32:43 +0000 (14:32 +0200)
If rate stays at 0, a FPE will be raised in SetupOutput.

modules/packetizer/mpeg4audio.c

index 03257f7258b4a9c266d084947478252b2737df91..29c441b25b8d8b9123f8fce7d8a42f10a589e799 100644 (file)
@@ -807,20 +807,23 @@ static int LOASParse( decoder_t *p_dec, uint8_t *p_buffer, int i_buffer )
             p_sys->i_rate = st->cfg.i_samplerate;
             p_sys->i_frame_length = st->cfg.i_frame_length;
 
-            /* FIXME And if it changes ? */
-            if( !p_dec->fmt_out.i_extra && st->i_extra > 0 )
+            if ( p_sys->i_channels > 0 && p_sys->i_rate > 0 &&
+                 p_sys->i_frame_length > 0 )
             {
-                p_dec->fmt_out.i_extra = st->i_extra;
-                p_dec->fmt_out.p_extra = malloc( st->i_extra );
-                if( !p_dec->fmt_out.p_extra )
+                /* FIXME And if it changes ? */
+                if( !p_dec->fmt_out.i_extra && st->i_extra > 0 )
                 {
-                    p_dec->fmt_out.i_extra = 0;
-                    return 0;
+                    p_dec->fmt_out.i_extra = st->i_extra;
+                    p_dec->fmt_out.p_extra = malloc( st->i_extra );
+                    if( !p_dec->fmt_out.p_extra )
+                    {
+                        p_dec->fmt_out.i_extra = 0;
+                        return 0;
+                    }
+                    memcpy( p_dec->fmt_out.p_extra, st->extra, st->i_extra );
                 }
-                memcpy( p_dec->fmt_out.p_extra, st->extra, st->i_extra );
+                p_sys->b_latm_cfg = true;
             }
-
-            p_sys->b_latm_cfg = true;
         }
     }
     /* Wait for the configuration */