Title: [184154] trunk/Source/WebCore
Revision
184154
Author
[email protected]
Date
2015-05-11 23:39:37 -0700 (Mon, 11 May 2015)

Log Message

Clean up redundant resources in case of failure in GLContextEGL context creation methods
https://bugs.webkit.org/show_bug.cgi?id=144878

Reviewed by Martin Robinson.

GLContextEGL::createWindowContext() and GLContextEGL::createPixmapContext() methods
should clean up the freshly-created resources when prematurely returning due to a
failure.

* platform/graphics/egl/GLContextEGL.cpp:
(WebCore::GLContextEGL::createWindowContext):
(WebCore::GLContextEGL::createPixmapContext):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (184153 => 184154)


--- trunk/Source/WebCore/ChangeLog	2015-05-12 05:51:21 UTC (rev 184153)
+++ trunk/Source/WebCore/ChangeLog	2015-05-12 06:39:37 UTC (rev 184154)
@@ -1,3 +1,18 @@
+2015-05-11  Zan Dobersek  <[email protected]>
+
+        Clean up redundant resources in case of failure in GLContextEGL context creation methods
+        https://bugs.webkit.org/show_bug.cgi?id=144878
+
+        Reviewed by Martin Robinson.
+
+        GLContextEGL::createWindowContext() and GLContextEGL::createPixmapContext() methods
+        should clean up the freshly-created resources when prematurely returning due to a
+        failure.
+
+        * platform/graphics/egl/GLContextEGL.cpp:
+        (WebCore::GLContextEGL::createWindowContext):
+        (WebCore::GLContextEGL::createPixmapContext):
+
 2015-05-11  Dan Bernstein  <[email protected]>
 
         WebCore part of <rdar://problem/20878075> Trying to navigate to an invalid URL loads about:blank, but -[WKWebView URL] returns the invalid URL

Modified: trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp (184153 => 184154)


--- trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2015-05-12 05:51:21 UTC (rev 184153)
+++ trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2015-05-12 06:39:37 UTC (rev 184154)
@@ -111,8 +111,10 @@
         return nullptr;
 
     EGLSurface surface = eglCreateWindowSurface(display, config, window, 0);
-    if (surface == EGL_NO_SURFACE)
+    if (surface == EGL_NO_SURFACE) {
+        eglDestroyContext(display, context);
         return nullptr;
+    }
 
     return std::make_unique<GLContextEGL>(context, surface, WindowSurface);
 }
@@ -157,18 +159,25 @@
         return nullptr;
 
     EGLint depth;
-    if (!eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depth))
+    if (!eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depth)) {
+        eglDestroyContext(display, context);
         return nullptr;
+    }
 
     Display* x11Display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();
     Pixmap pixmap = XCreatePixmap(x11Display, DefaultRootWindow(x11Display), 1, 1, depth);
-    if (!pixmap)
+    if (!pixmap) {
+        eglDestroyContext(display, context);
         return nullptr;
+    }
 
     EGLSurface surface = eglCreatePixmapSurface(display, config, pixmap, 0);
 
-    if (surface == EGL_NO_SURFACE)
+    if (surface == EGL_NO_SURFACE) {
+        XFreePixmap(x11Display, pixmap);
+        eglDestroyContext(display, context);
         return nullptr;
+    }
 
     return std::make_unique<GLContextEGL>(context, surface, PixmapSurface);
 #else
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to