WebGL Compat: forbid client side arrays, even unused

BUG=angleproject:2064

Change-Id: I9a9c2df9a158799dbdc490446352cdf30fb87ca6
Reviewed-on: https://chromium-review.googlesource.com/537812
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index 2fdb17e..1fa15f0 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -51,15 +51,17 @@
     for (size_t attributeIndex = 0; attributeIndex < maxEnabledAttrib; ++attributeIndex)
     {
         const VertexAttribute &attrib = vertexAttribs[attributeIndex];
-        if (!program->isAttribLocationActive(attributeIndex) || !attrib.enabled)
+
+        // No need to range check for disabled attribs.
+        if (!attrib.enabled)
         {
             continue;
         }
 
-        const VertexBinding &binding = vertexBindings[attrib.bindingIndex];
         // If we have no buffer, then we either get an error, or there are no more checks to be
         // done.
-        gl::Buffer *buffer = binding.getBuffer().get();
+        const VertexBinding &binding  = vertexBindings[attrib.bindingIndex];
+        gl::Buffer *buffer            = binding.getBuffer().get();
         if (!buffer)
         {
             if (webglCompatibility || !state.areClientArraysEnabled())
@@ -84,6 +86,13 @@
             continue;
         }
 
+        // This needs to come after the check for client arrays as even unused attributes cannot use
+        // client-side arrays
+        if (!program->isAttribLocationActive(attributeIndex))
+        {
+            continue;
+        }
+
         // If we're drawing zero vertices, we have enough data.
         if (vertexCount <= 0 || primcount <= 0)
         {