Fix glGetActiveUniform/Attrib crashes due to state inconsistency

between what Chrome thinks and what the driver is.

This is caused by we intercept invalid program and generate an error on
LinkProgram rather than passing it to the driver, so the driver still have
a valid program if the previous link succeeds.

BUG=463599
TEST=test case in the bug
R=sievers@chromium.org

Review URL: https://codereview.chromium.org/978193003

Cr-Commit-Position: refs/heads/master@{#319746}
diff --git a/gpu/blink/webgraphicscontext3d_impl.cc b/gpu/blink/webgraphicscontext3d_impl.cc
index 581e102..06185ff 100644
--- a/gpu/blink/webgraphicscontext3d_impl.cc
+++ b/gpu/blink/webgraphicscontext3d_impl.cc
@@ -361,11 +361,12 @@
       program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length);
   if (max_name_length < 0)
     return false;
-  scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
-  if (!name) {
-    synthesizeGLError(GL_OUT_OF_MEMORY);
+  if (max_name_length == 0) {
+    // No active attributes exist.
+    synthesizeGLError(GL_INVALID_VALUE);
     return false;
   }
+  scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
   GLsizei length = 0;
   GLint size = -1;
   GLenum type = 0;
@@ -387,11 +388,12 @@
       program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_name_length);
   if (max_name_length < 0)
     return false;
-  scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
-  if (!name) {
-    synthesizeGLError(GL_OUT_OF_MEMORY);
+  if (max_name_length == 0) {
+    // No active uniforms exist.
+    synthesizeGLError(GL_INVALID_VALUE);
     return false;
   }
+  scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
   GLsizei length = 0;
   GLint size = -1;
   GLenum type = 0;