From bd119bf2e3faa06751b1e5e65b59f0321bb7a998 Mon Sep 17 00:00:00 2001 From: bohu Date: Fri, 17 Oct 2014 13:48:06 -0700 Subject: [PATCH] Guard against negative width and height When negative width or height passes into pixelDataSize, some bogus values are returned. This commit checks both width and height to make sure they are valid. Change-Id: Ia49a9f464e6bb4894207ca4e07bbfdf34fbe741d --- shared/OpenglCodecCommon/GLClientState.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shared/OpenglCodecCommon/GLClientState.cpp b/shared/OpenglCodecCommon/GLClientState.cpp index 9795490..a84e856 100644 --- a/shared/OpenglCodecCommon/GLClientState.cpp +++ b/shared/OpenglCodecCommon/GLClientState.cpp @@ -224,6 +224,8 @@ int GLClientState::setPixelStore(GLenum param, GLint value) size_t GLClientState::pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack) const { + if (width <= 0 || height <= 0) return 0; + int pixelsize = glUtilsPixelBitSize(format, type) >> 3; int alignment = pack ? m_pixelStore.pack_alignment : m_pixelStore.unpack_alignment; -- 2.11.0