Use a map to store uniform locations instead of a vector.

Some intel drivers use seemingly arbitrary integers as uniform locations.
This causes the location vector to be resized to arbitrarily large sizes.

BUG=angleproject:882

Change-Id: I8db89178907dd6206eb8e646a0b426aa9bac0832
Reviewed-on: https://chromium-review.googlesource.com/274816
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/renderer/ProgramImpl.cpp b/src/libANGLE/renderer/ProgramImpl.cpp
index b0267ae..9da0c42 100644
--- a/src/libANGLE/renderer/ProgramImpl.cpp
+++ b/src/libANGLE/renderer/ProgramImpl.cpp
@@ -27,8 +27,8 @@
 
 gl::LinkedUniform *ProgramImpl::getUniformByLocation(GLint location) const
 {
-    ASSERT(location >= 0 && static_cast<size_t>(location) < mUniformIndex.size());
-    return mUniforms[mUniformIndex[location].index];
+    ASSERT(location >= 0 && mUniformIndex.find(location) != mUniformIndex.end());
+    return mUniforms[mUniformIndex.at(location).index];
 }
 
 gl::LinkedUniform *ProgramImpl::getUniformByName(const std::string &name) const
@@ -55,15 +55,16 @@
     size_t subscript = GL_INVALID_INDEX;
     std::string baseName = gl::ParseUniformName(name, &subscript);
 
-    unsigned int numUniforms = mUniformIndex.size();
-    for (unsigned int location = 0; location < numUniforms; location++)
+    for (const auto &info : mUniformIndex)
     {
-        if (mUniformIndex[location].name == baseName)
-        {
-            const int index = mUniformIndex[location].index;
-            const bool isArray = mUniforms[index]->isArray();
+        GLuint location = info.first;
+        const gl::VariableLocation &uniform = info.second;
 
-            if ((isArray && mUniformIndex[location].element == subscript) ||
+        if (uniform.name == baseName)
+        {
+            const bool isArray = mUniforms[uniform.index]->isArray();
+
+            if ((isArray && uniform.element == subscript) ||
                 (subscript == GL_INVALID_INDEX))
             {
                 return location;