From 431f3e0e6febb3cbcdd14d8aec0dcdfda26175ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Mon, 27 Jul 2015 18:44:53 -0400 Subject: [PATCH] avviddec: Only create the AVBuffer once the stride is validated If it is created earlier and the stride is invalid, then the frame will be freed and it won't be possible to use it in the fallback path. Not doing this causes a segfault because it will try to use already freed memory. --- ext/libav/gstavviddec.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ext/libav/gstavviddec.c b/ext/libav/gstavviddec.c index ee7f2f2d1a..811e51b249 100644 --- a/ext/libav/gstavviddec.c +++ b/ext/libav/gstavviddec.c @@ -696,11 +696,6 @@ gst_ffmpegviddec_get_buffer2 (AVCodecContext * context, AVFrame * picture, picture->data[c] = GST_VIDEO_FRAME_PLANE_DATA (&dframe->vframe, c); picture->linesize[c] = GST_VIDEO_FRAME_PLANE_STRIDE (&dframe->vframe, c); - if (c == 0) { - picture->buf[c] = - av_buffer_create (NULL, 0, dummy_free_buffer, dframe, 0); - } - /* libav does not allow stride changes currently, fall back to * non-direct rendering here: * https://bugzilla.gnome.org/show_bug.cgi?id=704769 @@ -733,6 +728,8 @@ gst_ffmpegviddec_get_buffer2 (AVCodecContext * context, AVFrame * picture, picture->data[c]); } + picture->buf[0] = av_buffer_create (NULL, 0, dummy_free_buffer, dframe, 0); + /* tell ffmpeg we own this buffer, tranfer the ref we have on the buffer to * the opaque data. */ picture->type = FF_BUFFER_TYPE_USER;