Fix two webgl crashes.

Uninitialized variable in getProgramInfoLog and friends.
Fix crash in GLES2DecoderImpl if resizing the <canvas> when parent_ is null.

BUG=44590
TEST=64-bit chrome on Linux is able to run the o3d-webgl samples.

Review URL: http://codereview.chromium.org/2819025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50861 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 3f30647..2cc4509a 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -1844,34 +1844,34 @@
         0,  // border
         GL_RGBA,
         GL_UNSIGNED_BYTE);
-  }
 
-  // Attach the saved offscreen color texture to a frame buffer so we can
-  // clear it with glClear.
-  offscreen_target_frame_buffer_->AttachRenderTexture(
-      offscreen_saved_color_texture_.get());
-  if (offscreen_target_frame_buffer_->CheckStatus() !=
-      GL_FRAMEBUFFER_COMPLETE) {
-    return false;
-  }
-
-  // TODO(apatrick): Fix this once ANGLE supports shared contexts.
-  // Clear the saved offscreen color texture. Use default GL context
-  // to ensure clear is not affected by client set state.
-  if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
-    ScopedDefaultGLContext scoped_context(this);
-    glBindFramebufferEXT(GL_FRAMEBUFFER,
-                         offscreen_target_frame_buffer_->id());
-    glClear(GL_COLOR_BUFFER_BIT);
-    glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
-
-    if (glGetError() != GL_NO_ERROR)
+    // Attach the saved offscreen color texture to a frame buffer so we can
+    // clear it with glClear.
+    offscreen_target_frame_buffer_->AttachRenderTexture(
+        offscreen_saved_color_texture_.get());
+    if (offscreen_target_frame_buffer_->CheckStatus() !=
+        GL_FRAMEBUFFER_COMPLETE) {
       return false;
-  }
+    }
 
-  // Re-attach the offscreen render texture to the target frame buffer.
-  offscreen_target_frame_buffer_->AttachRenderTexture(
-      offscreen_target_color_texture_.get());
+    // TODO(apatrick): Fix this once ANGLE supports shared contexts.
+    // Clear the saved offscreen color texture. Use default GL context
+    // to ensure clear is not affected by client set state.
+    if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
+      ScopedDefaultGLContext scoped_context(this);
+      glBindFramebufferEXT(GL_FRAMEBUFFER,
+                           offscreen_target_frame_buffer_->id());
+      glClear(GL_COLOR_BUFFER_BIT);
+      glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
+
+      if (glGetError() != GL_NO_ERROR)
+        return false;
+    }
+
+    // Re-attach the offscreen render texture to the target frame buffer.
+    offscreen_target_frame_buffer_->AttachRenderTexture(
+        offscreen_target_color_texture_.get());
+  }
 
   return true;
 }
@@ -4714,9 +4714,12 @@
     if (!UpdateOffscreenFrameBufferSize())
       return error::kLostContext;
 
-    ScopedFrameBufferBinder binder(this, offscreen_target_frame_buffer_->id());
-    offscreen_saved_color_texture_->Copy(
-        offscreen_saved_color_texture_->size());
+    if (parent_) {
+      ScopedFrameBufferBinder binder(this,
+                                     offscreen_target_frame_buffer_->id());
+      offscreen_saved_color_texture_->Copy(
+          offscreen_saved_color_texture_->size());
+    }
   } else {
     context_->SwapBuffers();
   }