[Mesa-dev] [PATCH 2/2] egl/dri2: do not leak dri2_dpy->driver_name
Emil Velikov
emil.l.velikov at gmail.com
Sun Jun 1 07:19:47 PDT 2014
Originally all hardware drivers duplicate the driver_name string
from an external source, while for the software rasterizer we've
set it to a literal. Follow the example set by hw drivers this way
we can free the string at dri2_terminate().
Cc: Chia-I Wu <olv at lunarg.com>
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
src/egl/drivers/dri2/egl_dri2.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index c1497b8..a2dc7ff 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -469,7 +469,11 @@ dri2_load_driver_swrast(_EGLDisplay *disp)
struct dri2_egl_display *dri2_dpy = disp->DriverData;
const __DRIextension **extensions;
- dri2_dpy->driver_name = "swrast";
+ /*
+ * Every hardware driver_name is set using strndup. Doing the same in
+ * here will allow is to simply free the memory at dri2_terminate().
+ */
+ dri2_dpy->driver_name = strndup("swrast", sizeof("swrast"));
extensions = dri2_open_driver(disp);
if (!extensions)
@@ -673,6 +677,7 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
if (dri2_dpy->driver)
dlclose(dri2_dpy->driver);
free(dri2_dpy->device_name);
+ free(dri2_dpy->driver_name);
switch (disp->Platform) {
#ifdef HAVE_X11_PLATFORM
--
1.9.3
More information about the mesa-dev
mailing list