OSDN Git Service

src_buffer: propagate errors from copy_buffer_ref()
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 17 May 2012 02:46:27 +0000 (04:46 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 17 May 2012 02:48:05 +0000 (04:48 +0200)
Fixes a null ptr deref

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavfilter/src_buffer.c

index b249a83..5bf629c 100644 (file)
@@ -270,6 +270,8 @@ static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx,
     case AVMEDIA_TYPE_VIDEO:
         buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
                                         ref->video->w, ref->video->h);
+        if(!buf)
+            return NULL;
         av_image_copy(buf->data, buf->linesize,
                       (void*)ref->data, ref->linesize,
                       ref->format, ref->video->w, ref->video->h);
@@ -278,6 +280,8 @@ static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx,
     case AVMEDIA_TYPE_AUDIO:
         buf = ff_get_audio_buffer(outlink, AV_PERM_WRITE,
                                         ref->audio->nb_samples);
+        if(!buf)
+            return NULL;
         channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout);
         av_samples_copy(buf->extended_data, ref->buf->extended_data,
                         0, 0, ref->audio->nb_samples,
@@ -319,6 +323,8 @@ int av_buffersrc_add_ref(AVFilterContext *buffer_filter,
         buf = picref;
     else
         buf = copy_buffer_ref(buffer_filter, picref);
+    if(!buf)
+        return -1;
 
     if ((ret = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) {
         if (buf != picref)