Commit ac87c273 authored by Michael Niedermayer's avatar Michael Niedermayer

src_buffer: propagate errors from copy_buffer_ref()

Fixes a null ptr deref
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 3c001321
...@@ -270,6 +270,8 @@ static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx, ...@@ -270,6 +270,8 @@ static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx,
case AVMEDIA_TYPE_VIDEO: case AVMEDIA_TYPE_VIDEO:
buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
ref->video->w, ref->video->h); ref->video->w, ref->video->h);
if(!buf)
return NULL;
av_image_copy(buf->data, buf->linesize, av_image_copy(buf->data, buf->linesize,
(void*)ref->data, ref->linesize, (void*)ref->data, ref->linesize,
ref->format, ref->video->w, ref->video->h); ref->format, ref->video->w, ref->video->h);
...@@ -278,6 +280,8 @@ static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx, ...@@ -278,6 +280,8 @@ static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx,
case AVMEDIA_TYPE_AUDIO: case AVMEDIA_TYPE_AUDIO:
buf = ff_get_audio_buffer(outlink, AV_PERM_WRITE, buf = ff_get_audio_buffer(outlink, AV_PERM_WRITE,
ref->audio->nb_samples); ref->audio->nb_samples);
if(!buf)
return NULL;
channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout); channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout);
av_samples_copy(buf->extended_data, ref->buf->extended_data, av_samples_copy(buf->extended_data, ref->buf->extended_data,
0, 0, ref->audio->nb_samples, 0, 0, ref->audio->nb_samples,
...@@ -319,6 +323,8 @@ int av_buffersrc_add_ref(AVFilterContext *buffer_filter, ...@@ -319,6 +323,8 @@ int av_buffersrc_add_ref(AVFilterContext *buffer_filter,
buf = picref; buf = picref;
else else
buf = copy_buffer_ref(buffer_filter, picref); 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 ((ret = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) {
if (buf != picref) if (buf != picref)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment