egl_dri2: check if device_name is NULL before releasing it

Submitted by Zhaowei Yuan on Oct. 30, 2018, 7:09 a.m.

Details

Message ID 1540883365-15916-1-git-send-email-zhaowei.yuan@samsung.com
State New
Headers show
Series "egl_dri2: check if device_name is NULL before releasing it" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Zhaowei Yuan Oct. 30, 2018, 7:09 a.m.
Pointer dri2_dpy->device_name is probably NULL when calling
dri2_display_destory, check this before releasing it.

Signed-off-by: Zhaowei Yuan <zhaowei.yuan@samsung.com>
---
 src/egl/drivers/dri2/egl_dri2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index c5fa935..60ae484 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -970,7 +970,8 @@  dri2_display_destroy(_EGLDisplay *disp)
    free(dri2_dpy->driver_name);
 
 #ifdef HAVE_WAYLAND_PLATFORM
-   free(dri2_dpy->device_name);
+   if (dri2_dpy->device_name)
+      free(dri2_dpy->device_name);
 #endif
 
    switch (disp->Platform) {

Comments

On Tue, 30 Oct 2018 at 07:13, Zhaowei Yuan <zhaowei.yuan@samsung.com> wrote:
>
> Pointer dri2_dpy->device_name is probably NULL when calling
> dri2_display_destory, check this before releasing it.
>
According to the man page, free(NULL) is perfectly valid and safe.

-Emil