ProgramGL: correctly copy sampler uniforms

BUG=angleproject:1570

Change-Id: Ic39f5f1ff8f565b2876fdfc8d738a50f24b911b6
Reviewed-on: https://chromium-review.googlesource.com/402930
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/renderer/gl/ProgramGL.cpp b/src/libANGLE/renderer/gl/ProgramGL.cpp
index e6ec589..7ca08e9 100644
--- a/src/libANGLE/renderer/gl/ProgramGL.cpp
+++ b/src/libANGLE/renderer/gl/ProgramGL.cpp
@@ -223,7 +223,7 @@
         std::vector<GLuint> &boundTextureUnits = mSamplerBindings[samplerIndex].boundTextureUnits;
 
         size_t copyCount =
-            std::max<size_t>(count, boundTextureUnits.size() - locationEntry.element);
+            std::min<size_t>(count, boundTextureUnits.size() - locationEntry.element);
         std::copy(v, v + copyCount, boundTextureUnits.begin() + locationEntry.element);
     }
 }