af_aresample: allocate at least 1 sample buffer. Fix null ptr dereference.
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 19 Nov 2012 14:55:23 +0000 (15:55 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 19 Nov 2012 14:55:54 +0000 (15:55 +0100)
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavfilter/af_aresample.c

index 53c5dcd..7201d37 100644 (file)
@@ -174,12 +174,11 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref)
 {
     AResampleContext *aresample = inlink->dst->priv;
     const int n_in  = insamplesref->audio->nb_samples;
-    int n_out       = n_in * aresample->ratio * 2 ;
+    int n_out       = FFMAX(n_in * aresample->ratio * 2, 1);
     AVFilterLink *const outlink = inlink->dst->outputs[0];
     AVFilterBufferRef *outsamplesref = ff_get_audio_buffer(outlink, AV_PERM_WRITE, n_out);
     int ret;
 
-
     avfilter_copy_buffer_ref_props(outsamplesref, insamplesref);
     outsamplesref->format                = outlink->format;
     outsamplesref->audio->channel_layout = outlink->channel_layout;