Fix array iteration range
authorJari Komppa <jari.komppa@siru.fi>
Thu, 4 Nov 2021 11:25:30 +0000 (13:25 +0200)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Sat, 13 Nov 2021 16:04:43 +0000 (16:04 +0000)
The function getCompressedTexSubImage2DFormat was using function
parameter to loop through an array defined inside the function, while
these two were unrelated. The result may either not loop through the
whole array or go past the end of the array.

Affects:
dEQP-GLES2.functional.negative_api.texture.compressedtexsubimage2d_*

Components: OpenGL
VK-GL-CTS issue: 3272

Change-Id: Ie88d9330e03f56b7afe858bf51e9bf0fa41e4822

modules/gles2/functional/es2fNegativeTextureApiTests.cpp

index fcf2dba..0f588e8 100644 (file)
@@ -86,7 +86,7 @@ static void getCompressedTexSubImage2DFormat(const vector<deInt32>& supported, v
                0x8C03  // GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
        };
 
-       for (int i = 0; i < (int)supported.size(); i++)
+       for (int i = 0; i < DE_LENGTH_OF_ARRAY(compressedTexSubImage2DFormats); i++)
        {
                vector<deInt32>::const_iterator fmt = std::find(supported.begin(), supported.end(), compressedTexSubImage2DFormats[i]);
                if (fmt != supported.end())