Fixed validation errors in teximage3d and friends.

BUG=angleproject:1169
BUG=angleproject:1101

Change-Id: I3770335d04cafd652c2f3839afca3e4a854e6e76
Reviewed-on: https://chromium-review.googlesource.com/322381
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tryjob-Request: Jamie Madill <jmadill@chromium.org>
Tested-by: Ian Ewell <ewell@google.com>
diff --git a/src/libANGLE/validationES2.cpp b/src/libANGLE/validationES2.cpp
index 5f9bf55..6ec11d9 100644
--- a/src/libANGLE/validationES2.cpp
+++ b/src/libANGLE/validationES2.cpp
@@ -458,6 +458,12 @@
 {
     GLenum textureInternalFormat = GL_NONE;
 
+    if (!ValidTexture2DDestinationTarget(context, target))
+    {
+        context->recordError(Error(GL_INVALID_ENUM, "Invalid texture target"));
+        return false;
+    }
+
     if (!ValidateCopyTexImageParametersBase(context, target, level, internalformat, isSubImage,
                                             xoffset, yoffset, 0, x, y, width, height, border, &textureInternalFormat))
     {