egl/dri2: Fix const pointer duplication, prevent unitialized variable dereference.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 12 May 2011 14:23:02 +0000 (15:23 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 12 May 2011 14:23:02 +0000 (15:23 +0100)
Based on zhigang gong <zhigang.gong@gmail.com>'s patch.

src/egl/drivers/dri2/platform_drm.c

index 261cbfed6758b5efb5044df2cc0832456e360d7d..9811b280299c4856fb7d05dcc7d33c7b557a69ce 100644 (file)
@@ -581,7 +581,8 @@ dri2_get_device_name(int fd)
    struct udev *udev;
    struct udev_device *device;
    struct stat buf;
-   char *device_name;
+   const char *const_device_name;
+   char *device_name = NULL;
 
    udev = udev_new();
    if (fstat(fd, &buf) < 0) {
@@ -596,10 +597,11 @@ dri2_get_device_name(int fd)
       goto out;
    }
 
-   device_name = udev_device_get_devnode(device);
-   if (!device_name)
-          goto out;
-   device_name = strdup(device_name);
+   const_device_name = udev_device_get_devnode(device);
+   if (!const_device_name) {
+      goto out;
+   }
+   device_name = strdup(const_device_name);
 
  out:
    udev_device_unref(device);