From c4374041ac0202275556db56b62ca34057433c7a Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 10 Sep 2010 14:40:10 -0700 Subject: [PATCH] reject odd widths or heights for YV12 format Change-Id: I66cbb5fbc20630218947cd41552a95503b58e15e --- gpu.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gpu.cpp b/gpu.cpp index d577f96..90ff445 100644 --- a/gpu.cpp +++ b/gpu.cpp @@ -239,8 +239,12 @@ int gpu_context_t::alloc_impl(int w, int h, int format, int usage, break; case HAL_PIXEL_FORMAT_YV12: + if ((w&1) || (h&1)) { + LOGE("w or h is odd for HAL_PIXEL_FORMAT_YV12"); + return -EINVAL; + } alignedw = ALIGN(w, 16); - alignedh = ALIGN(h, 2); + alignedh = h; size = alignedw*alignedh + (ALIGN(alignedw/2, 16) * (alignedh/2))*2; break;