From b25182a61d75eeb50412cb678c47e527b4d6f921 Mon Sep 17 00:00:00 2001 From: Sameer Kibey Date: Tue, 18 Feb 2014 13:17:11 -0800 Subject: [PATCH] Fix a memory corruption to prevent segfault in VP8 Fixed a memory corruption in psb-video. Check the value of numAdapt before modifying the info[] in GetPortId. Without this check it will cause a memory corruption leading to intermittent segfaults in Chrome browser. Change-Id: I1bae44886e9cb0deab8aa5abe5ceafa6e778350d Signed-off-by: Sameer Kibey --- src/x11/psb_xvva.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/x11/psb_xvva.c b/src/x11/psb_xvva.c index 4e2a719..a0af061 100644 --- a/src/x11/psb_xvva.c +++ b/src/x11/psb_xvva.c @@ -70,8 +70,14 @@ static int GetPortId(VADriverContextP ctx, psb_x11_output_p output) Display *dpy = (Display *)ctx->native_dpy; ret = XvQueryAdaptors(dpy, DefaultRootWindow(dpy), &numAdapt, &info); - /*Force overlay port num equal to one. OverlayC can't be used independently now.*/ - info[1].num_ports = 1; + + /* check for numAdapt before modifying the info[1]. Without this check + * it will cause a memory corruption leading to segfaults */ + if (numAdapt > 1) + { + /*Force overlay port num equal to one. OverlayC can't be used independently now.*/ + info[1].num_ports = 1; + } if (Success != ret) { drv_debug_msg(VIDEO_DEBUG_ERROR, "Can't find Xvideo adaptor\n");