[FFmpeg-devel] [PATCH] lavfi/avcodec: add consistency checks in avfilter_copy_buf_props()
Stefano Sabatini
stefasab at gmail.com
Sun Jun 10 18:34:30 CEST 2012
Fix possible crash.
---
libavfilter/avcodec.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/libavfilter/avcodec.c b/libavfilter/avcodec.c
index 6b23772..4ef7eb2 100644
--- a/libavfilter/avcodec.c
+++ b/libavfilter/avcodec.c
@@ -83,6 +83,8 @@ int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
{
int planes, nb_channels;
+ if (!dst || !src)
+ return AVERROR(EINVAL);
memcpy(dst->data, src->data, sizeof(dst->data));
memcpy(dst->linesize, src->linesize, sizeof(dst->linesize));
@@ -91,6 +93,8 @@ int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
switch (src->type) {
case AVMEDIA_TYPE_VIDEO:
+ if (!src->video)
+ return AVERROR(EINVAL);
dst->width = src->video->w;
dst->height = src->video->h;
dst->sample_aspect_ratio = src->video->sample_aspect_ratio;
@@ -100,6 +104,8 @@ int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
dst->pict_type = src->video->pict_type;
break;
case AVMEDIA_TYPE_AUDIO:
+ if (!src->audio)
+ return AVERROR(EINVAL);
nb_channels = av_get_channel_layout_nb_channels(src->audio->channel_layout);
planes = av_sample_fmt_is_planar(src->format) ? nb_channels : 1;
--
1.7.5.4
More information about the ffmpeg-devel
mailing list