[Mesa-dev] [PATCH] egl/x11: Fix driver_name acquisition

Boyan Ding boyan.j.ding at gmail.com
Sat Aug 8 02:23:28 PDT 2015


We don't need to free driverName string from dri2 reply, on the other
hand, the driver name acquired from loader doesn't need duplication.

This fixes commit 45e110ba

Cc: Emil Velikov <emil.l.velikov at gmail.com>
Reported-by: Timothy Arceri <t_arceri at yahoo.com.au>
Signed-off-by: Boyan Ding <boyan.j.ding at gmail.com>
---
 src/egl/drivers/dri2/platform_x11.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index 61e5b77..ee5b53f 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -601,15 +601,14 @@ dri2_x11_connect(struct dri2_egl_display *dri2_dpy)
     * Otherwise, default to the server's value.
     */
    loader_driver_name = loader_get_driver_for_fd(dri2_dpy->fd, 0);
-   if (loader_driver_name) {
-      free(driver_name);
-      driver_name = loader_driver_name;
+   if (loader_driver_name)
+      dri2_dpy->driver_name = loader_driver_name;
+   else {
+      dri2_dpy->driver_name =
+         strndup(driver_name,
+                 xcb_dri2_connect_driver_name_length(connect));
    }
 
-   dri2_dpy->driver_name =
-      strndup(driver_name,
-              xcb_dri2_connect_driver_name_length(connect));
-
    if (dri2_dpy->device_name == NULL || dri2_dpy->driver_name == NULL) {
       close(dri2_dpy->fd);
       free(dri2_dpy->device_name);
-- 
2.5.0



More information about the mesa-dev mailing list