dri_glx: fix use after free report
authorDave Airlie <airlied@gmail.com>
Fri, 30 Nov 2012 07:47:47 +0000 (17:47 +1000)
committerDave Airlie <airlied@gmail.com>
Sat, 1 Dec 2012 01:20:36 +0000 (11:20 +1000)
the critical error would use driverName.

Found by internal RH coverity scan.

Note: This is a candidate for stable branches.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/glx/dri_glx.c

index de777fbba8b7f580fc9553af3da629bc2e6864fb..f42db79ad61760d7c120a1e2873ae61d1b095fa0 100644 (file)
@@ -805,7 +805,6 @@ driCreateScreen(int screen, struct glx_display *priv)
    }
 
    psc->driver = driOpenDriver(driverName);
-   free(driverName);
    if (psc->driver == NULL)
       goto cleanup;
 
@@ -847,11 +846,15 @@ driCreateScreen(int screen, struct glx_display *priv)
    psp->setSwapInterval = driSetSwapInterval;
    psp->getSwapInterval = driGetSwapInterval;
 
+   free(driverName);
+
    return &psc->base;
 
 cleanup:
    CriticalErrorMessageF("failed to load driver: %s\n", driverName);
 
+   free(driverName);
+
    if (psc->driver)
       dlclose(psc->driver);
    glx_screen_cleanup(&psc->base);