From c40d7ef125cfad6a386a75f19dcdb13b328a3d06 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Fri, 3 Aug 2012 14:44:35 -0700 Subject: [PATCH] fix alpha-plane check + add extra checks Change-Id: I9d8c9743f9d4f3d394544773ed2d0c31a9acf24d --- src/dec/buffer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/dec/buffer.c b/src/dec/buffer.c index e491d4c4..c159f6f2 100644 --- a/src/dec/buffer.c +++ b/src/dec/buffer.c @@ -51,18 +51,23 @@ static VP8StatusCode CheckDecBuffer(const WebPDecBuffer* const buffer) { ok &= (y_size <= buf->y_size); ok &= (u_size <= buf->u_size); ok &= (v_size <= buf->v_size); - ok &= (a_size <= buf->a_size); ok &= (buf->y_stride >= width); ok &= (buf->u_stride >= (width + 1) / 2); ok &= (buf->v_stride >= (width + 1) / 2); - if (buf->a) { + ok &= (buf->y != NULL); + ok &= (buf->u != NULL); + ok &= (buf->v != NULL); + if (mode == MODE_YUVA) { ok &= (buf->a_stride >= width); + ok &= (a_size <= buf->a_size); + ok &= (buf->a != NULL); } } else { // RGB checks const WebPRGBABuffer* const buf = &buffer->u.RGBA; const uint64_t size = (uint64_t)buf->stride * height; ok &= (size <= buf->size); ok &= (buf->stride >= width * kModeBpp[mode]); + ok &= (buf->rgba != NULL); } return ok ? VP8_STATUS_OK : VP8_STATUS_INVALID_PARAM; }