Title: [120673] trunk/Source/WebCore
Revision
120673
Author
mrobin...@webkit.org
Date
2012-06-18 22:34:37 -0700 (Mon, 18 Jun 2012)

Log Message

[Cairo] Fix memory leaks in GLContextGLX.cpp
https://bugs.webkit.org/show_bug.cgi?id=89346

Patch by Sudarsana Nagineni <sudarsana.nagin...@linux.intel.com> on 2012-06-18
Reviewed by Martin Robinson.

Fix memory leaks found in GLContextGLX.cpp.

* platform/graphics/glx/GLContextGLX.cpp:
(WebCore::GLContextGLX::cleanupActiveContextsAtExit): Removing element reduces
size of the vector, so the loop termination condition was failing in the last
iteration, when the vector contains more than one element. This patch fixes the
issue by iterating the vector backwards, so the termination condition doesn't
fail until the size() reaches 0.
(WebCore::GLContextGLX::createPbufferContext): Delete GLXPbuffer
returned by glXCreatePbuffer().
(WebCore::GLContextGLX::createPixmapContext): Delete XVisualInfo
returned by glXChooseVisual().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (120672 => 120673)


--- trunk/Source/WebCore/ChangeLog	2012-06-19 05:19:46 UTC (rev 120672)
+++ trunk/Source/WebCore/ChangeLog	2012-06-19 05:34:37 UTC (rev 120673)
@@ -1,3 +1,23 @@
+2012-06-18  Sudarsana Nagineni  <sudarsana.nagin...@linux.intel.com>
+
+        [Cairo] Fix memory leaks in GLContextGLX.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=89346
+
+        Reviewed by Martin Robinson.
+
+        Fix memory leaks found in GLContextGLX.cpp.
+
+        * platform/graphics/glx/GLContextGLX.cpp:
+        (WebCore::GLContextGLX::cleanupActiveContextsAtExit): Removing element reduces
+        size of the vector, so the loop termination condition was failing in the last
+        iteration, when the vector contains more than one element. This patch fixes the
+        issue by iterating the vector backwards, so the termination condition doesn't
+        fail until the size() reaches 0.
+        (WebCore::GLContextGLX::createPbufferContext): Delete GLXPbuffer
+        returned by glXCreatePbuffer().
+        (WebCore::GLContextGLX::createPixmapContext): Delete XVisualInfo
+        returned by glXChooseVisual().
+
 2012-06-18  Gregg Tavares  <g...@google.com>
 
         Expose WEBGL_depth_texture extension to WebGL

Modified: trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp (120672 => 120673)


--- trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp	2012-06-19 05:19:46 UTC (rev 120672)
+++ trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp	2012-06-19 05:34:37 UTC (rev 120673)
@@ -60,8 +60,15 @@
     activeContextList().append(context);
 }
 
+static bool gCleaningUpAtExit = false;
+
 void GLContextGLX::removeActiveContext(GLContext* context)
 {
+    // If we are cleaning up the context list at exit, don't bother removing the context
+    // from the list, since we don't want to modify the list while it's being iterated.
+    if (gCleaningUpAtExit)
+        return;
+
     ActiveContextList& contextList = activeContextList();
     size_t i = contextList.find(context);
     if (i != notFound)
@@ -70,6 +77,8 @@
 
 void GLContextGLX::cleanupActiveContextsAtExit()
 {
+    gCleaningUpAtExit = true;
+
     ActiveContextList& contextList = activeContextList();
     for (size_t i = 0; i < contextList.size(); ++i)
         delete contextList[i];
@@ -138,8 +147,10 @@
 
     GLXContext context = glXCreateNewContext(display, configs[0], GLX_RGBA_TYPE, sharingContext, GL_TRUE);
     XFree(configs);
-    if (!context)
+    if (!context) {
+        glXDestroyPbuffer(display, pbuffer);
         return nullptr;
+    }
 
     // GLXPbuffer and XID are both the same types underneath, so we have to share
     // a constructor here with the window path.
@@ -183,6 +194,7 @@
         return nullptr;
     }
 
+    XFree(visualInfo);
     return adoptPtr(new GLContextGLX(context, pixmap, glxPixmap));
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to