[glx 1/7] glx/glxdri.c: Fix memory leak of context

Niels Thykier niels at thykier.net
Fri Nov 2 02:41:47 PDT 2012


Signed-off-by: Niels Thykier <niels at thykier.net>
---
 glx/glxdri.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/glx/glxdri.c b/glx/glxdri.c
index a5d87ec..57549af 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -645,8 +645,10 @@ __glXDRIscreenCreateContext(__GLXscreen * baseScreen,
     for (i = 0; i < pScreen->numVisuals; i++, visual++)
         if (visual->vid == glxConfig->visualID)
             break;
-    if (i == pScreen->numVisuals)
+    if (i == pScreen->numVisuals) {
+        free(context);
         return NULL;
+    }
 
     context->hwContextID = FakeClientID(0);
 
@@ -655,8 +657,10 @@ __glXDRIscreenCreateContext(__GLXscreen * baseScreen,
                               context->hwContextID, &hwContext);
     __glXleaveServer(GL_FALSE);
 
-    if (!retval)
+    if (!retval) {
+        free(context);
         return NULL;
+    }
 
     context->driContext = screen->legacy->createNewContext(screen->driScreen, config->driConfig, 0,     /* render type */
                                                            driShare,
-- 
1.7.10.4



More information about the xorg-devel mailing list