[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Fwd: Mesa dri2: memory leak at dri2_glx.c



Hello.

Sorry if I'm sending this for the wrong mail (please, let me know).

I'm writing a few small programs  using OpenGL, and I'm kinda a memory
leak paranoic (I like hibernation mode instead of shutdown). Anyway, I
saw some memory leaks at MesaLib. I tried to contact the author of the
dri2_glx.c, but the mail got back. It's decribed below.

Regards.

---------- Forwarded message ----------
From: Rodolfo Ribeiro Gomes <rodolforg@gmail.com>
Date: 2010/1/25
Subject: Mesa dri2: memory leak at dri2_glx.c
To: krh@redhat.com


Hello,

the function dri2CreateScreen() at src/glx/x11/dri2_glx.c (from
MesaLib package 7.6.1 and 7.7 at least) has memory leak.
It returns without free the __GLXDRIscreen *psp variable on errors.

A less intrusive modification is below. Maybe it would be better if
the drivername and devicename had been free as soon as they become
useless.

*** dri2_glx.c  2010-01-25 10:28:35.000000000 -0200
--- dri2_glx-modified.c 2010-01-25 10:33:21.000000000 -0200
***************
*** 438,444 ****
--- 438,447 ----

    if (!DRI2Connect(psc->dpy, RootWindow(psc->dpy, screen),
                     &driverName, &deviceName))
+    {
+       XFree(psp):
       return NULL;
+    }

    psc->driver = driOpenDriver(driverName);
    if (psc->driver == NULL) {
***************
*** 467,483 ****
    psc->fd = open(deviceName, O_RDWR);
    if (psc->fd < 0) {
       ErrorMessageF("failed to open drm device: %s\n", strerror(errno));
!       return NULL;
    }

    if (drmGetMagic(psc->fd, &magic)) {
       ErrorMessageF("failed to get magic\n");
!       return NULL;
    }

    if (!DRI2Authenticate(psc->dpy, RootWindow(psc->dpy, screen), magic)) {
       ErrorMessageF("failed to authenticate magic %d\n", magic);
!       return NULL;
    }

    /* If the server does not support the protocol for
--- 470,486 ----
    psc->fd = open(deviceName, O_RDWR);
    if (psc->fd < 0) {
       ErrorMessageF("failed to open drm device: %s\n", strerror(errno));
!       goto handle_error;
    }

    if (drmGetMagic(psc->fd, &magic)) {
       ErrorMessageF("failed to get magic\n");
!       goto handle_error;
    }

    if (!DRI2Authenticate(psc->dpy, RootWindow(psc->dpy, screen), magic)) {
       ErrorMessageF("failed to authenticate magic %d\n", magic);
!       goto handle_error;
    }

    /* If the server does not support the protocol for
***************
*** 491,497 ****

    if (psc->__driScreen == NULL) {
       ErrorMessageF("failed to create dri screen\n");
!       return NULL;
    }

    driBindExtensions(psc, 1);
--- 494,500 ----

    if (psc->__driScreen == NULL) {
       ErrorMessageF("failed to create dri screen\n");
!       goto handle_error;
    }

    driBindExtensions(psc, 1);
***************
*** 521,526 ****
--- 524,532 ----
  handle_error:
    Xfree(driverName);
    Xfree(deviceName);
+
+    XFree(psp):
+

    /* FIXME: clean up here */


Reply to: