Bug 576375 LayerManagerOGL::Initialize leaks p in SHADER_PROGRAM when p->Initialize fails
authortimeless@mozdev.org
Fri, 02 Jul 2010 17:31:08 +0300
changeset 47260 efdf011e85f0b76aa1043195ea574aae9fba7916
parent 47259 fd284df37f4fefaac5c67e6feec79b80c00b7b08
child 47261 5eb6ee0a512b8c57e2d193e049a827f53332517a
push id14299
push usertimeless@mozdev.org
push dateWed, 07 Jul 2010 20:28:45 +0000
treeherdermozilla-central@a9356e0479d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs576375
milestone2.0b2pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 576375 LayerManagerOGL::Initialize leaks p in SHADER_PROGRAM when p->Initialize fails r=vlad
gfx/layers/opengl/LayerManagerOGL.cpp
--- a/gfx/layers/opengl/LayerManagerOGL.cpp
+++ b/gfx/layers/opengl/LayerManagerOGL.cpp
@@ -112,22 +112,24 @@ LayerManagerOGL::Initialize(GLContext *a
 
   mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
                                  LOCAL_GL_ONE, LOCAL_GL_ONE);
   mGLContext->fEnable(LOCAL_GL_BLEND);
 
   // We unfortunately can't do generic initialization here, since the
   // concrete type actually matters.  This macro generates the
   // initialization using a concrete type and index.
-#define SHADER_PROGRAM(penum, ptype, vsstr, fsstr) do {                 \
+#define SHADER_PROGRAM(penum, ptype, vsstr, fsstr) do {                           \
     NS_ASSERTION(programIndex++ == penum, "out of order shader initialization!"); \
-    ptype *p = new ptype(mGLContext);                                   \
-    if (!p->Initialize(vsstr, fsstr))                                   \
-      return PR_FALSE;                                                  \
-    mPrograms.AppendElement(p);                                         \
+    ptype *p = new ptype(mGLContext);                                             \
+    if (!p->Initialize(vsstr, fsstr)) {                                           \
+      delete p;                                                                   \
+      return PR_FALSE;                                                            \
+    }                                                                             \
+    mPrograms.AppendElement(p);                                                   \
   } while (0)
 
 
   // NOTE: Order matters here, and should be in the same order as the
   // ProgramType enum!
   GLint programIndex = 0;
 
   /* Layer programs */