From 96cb7f12003c49de4b9462e237eade317371fcce Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mika=20Isoj=C3=A4rvi?= Date: Thu, 10 Mar 2016 14:16:47 -0800 Subject: [PATCH] Fix out of bounds access in internal format query tests Bug: 27570736 Change-Id: Id95f80765b3ed020515edb544cf871282672d802 --- modules/gles31/functional/es31fInternalFormatQueryTests.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/gles31/functional/es31fInternalFormatQueryTests.cpp b/modules/gles31/functional/es31fInternalFormatQueryTests.cpp index 55b6e6a..013f357 100644 --- a/modules/gles31/functional/es31fInternalFormatQueryTests.cpp +++ b/modules/gles31/functional/es31fInternalFormatQueryTests.cpp @@ -140,13 +140,11 @@ FormatSamplesCase::IterateResult FormatSamplesCase::iterate (void) // Sample counts { - tcu::MessageBuilder samplesMsg(&m_testCtx.getLog()); - std::vector samples; + tcu::MessageBuilder samplesMsg (&m_testCtx.getLog()); + std::vector samples (numSampleCounts > 0 ? numSampleCounts : 1); if (numSampleCounts > 0 || isFloatFormat) { - samples.resize(numSampleCounts, -1); - gl.getInternalformativ(m_target, m_internalFormat, GL_SAMPLES, numSampleCounts, &samples[0]); GLU_EXPECT_NO_ERROR(gl.getError(), "get GL_SAMPLES"); } @@ -156,7 +154,7 @@ FormatSamplesCase::IterateResult FormatSamplesCase::iterate (void) // make a pretty log samplesMsg << "GL_SAMPLES = ["; - for (int ndx = 0; ndx < numSampleCounts; ++ndx) + for (size_t ndx = 0; ndx < samples.size(); ++ndx) { if (ndx) samplesMsg << ", "; @@ -165,7 +163,7 @@ FormatSamplesCase::IterateResult FormatSamplesCase::iterate (void) samplesMsg << "]" << tcu::TestLog::EndMessage; // Samples are in order - for (int ndx = 1; ndx < numSampleCounts; ++ndx) + for (size_t ndx = 1; ndx < samples.size(); ++ndx) { if (samples[ndx-1] <= samples[ndx]) { @@ -176,7 +174,7 @@ FormatSamplesCase::IterateResult FormatSamplesCase::iterate (void) } // samples are positive - for (int ndx = 1; ndx < numSampleCounts; ++ndx) + for (size_t ndx = 1; ndx < samples.size(); ++ndx) { if (samples[ndx-1] <= 0) { -- 2.7.4