Fix out of bounds accesses in TexImage*DParamsCase.
authorMika Isojärvi <misojarvi@google.com>
Tue, 7 Feb 2017 20:52:54 +0000 (12:52 -0800)
committerMika Isojärvi <misojarvi@google.com>
Tue, 7 Feb 2017 20:52:54 +0000 (12:52 -0800)
Bug: 28764822
Test: Ran the tests on couple of devices and checked the results.
Change-Id: I3f743bf75d73ce7de7ff2b0633551c0cc7606ca0

modules/gles3/functional/es3fTextureSpecificationTests.cpp

index 8e5b0ec..3a634a8 100644 (file)
@@ -1080,14 +1080,13 @@ protected:
                int                                             pixelSize               = m_texFormat.getPixelSize();
                int                                             rowLength               = m_rowLength > 0 ? m_rowLength : m_width;
                int                                             rowPitch                = deAlign32(rowLength*pixelSize, m_alignment);
-               int                                             height                  = m_height + m_skipRows;
                deUint32                                tex                             = 0;
                vector<deUint8>                 data;
 
                DE_ASSERT(m_numLevels == 1);
 
                // Fill data with grid.
-               data.resize(rowPitch*height);
+               data.resize(pixelSize * m_skipPixels + rowPitch * (m_height + m_skipRows));
                {
                        Vec4    cScale          = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
                        Vec4    cBias           = m_texFormatInfo.valueMin;
@@ -1157,7 +1156,7 @@ protected:
                DE_ASSERT(m_numLevels == 1);
 
                // Fill data with grid.
-               data.resize(slicePitch*(m_depth+m_skipImages));
+               data.resize(pixelSize * m_skipPixels + rowPitch * m_skipRows + slicePitch * (m_skipImages + m_depth));
                {
                        Vec4    cScale          = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
                        Vec4    cBias           = m_texFormatInfo.valueMin;