Fix crash if av_vdpau_bind_context() is not used.
authorIvan Kalvachev <ikalvachev@gmail.com>
Sun, 8 Oct 2017 23:40:26 +0000 (02:40 +0300)
committerCarl Eugen Hoyos <ceffmpeg@gmail.com>
Thu, 12 Oct 2017 22:13:17 +0000 (00:13 +0200)
The public functions av_alloc_vdpaucontext() and
av_vdpau_alloc_context() are allocating AVVDPAUContext
structure that is supposed to be placed in avctx->hwaccel_context.

However the rest of libavcodec/vdpau.c uses avctx->hwaccel_context
as struct VDPAUHWContext, that is bigger and does contain
AVVDPAUContext as first member.

The usage includes write to the new variables in the bigger stuct,
without checking for block size.

Fix by always allocating the bigger structure.

Signed-off-by: Ivan Kalvachev <ikalvachev@gmail.com>
libavcodec/vdpau.c

index 42ebddbeeee2eee5fa4aad41a56dd1f7da67a49d..4cc51cb79ed12f99b0dce1e31d820f2f8b6735f6 100644 (file)
@@ -816,7 +816,7 @@ do {                                       \
 
 AVVDPAUContext *av_vdpau_alloc_context(void)
 {
-    return av_mallocz(sizeof(AVVDPAUContext));
+    return av_mallocz(sizeof(VDPAUHWContext));
 }
 
 int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device,