From ddda110ba0582567783615e544139ad1143e5334 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 23 Sep 2016 13:15:14 +0900 Subject: [PATCH] check if the wl_buffer is null Change-Id: I8ef619cbc11bc591766de08428332ba8d37cf476 --- src/wayland-tbm-client.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/wayland-tbm-client.c b/src/wayland-tbm-client.c index f28df2a..7749aea 100644 --- a/src/wayland-tbm-client.c +++ b/src/wayland-tbm-client.c @@ -857,12 +857,14 @@ handle_tbm_queue_buffer_attached(void *data, uint32_t flags) { struct wayland_tbm_surface_queue *queue_info = data; - struct wayland_tbm_buffer *buffer; + struct wayland_tbm_buffer *buffer = NULL; + + WL_TBM_RETURN_IF_FAIL(wl_buffer != NULL); WL_TBM_LOG("attached wl_buffer:%u", (unsigned int)wl_proxy_get_id((struct wl_proxy *)wl_buffer)); buffer = calloc(1, sizeof(struct wayland_tbm_buffer)); - WL_TBM_GOTO_IF_FAIL(buffer != NULL, fail); + WL_TBM_RETURN_IF_FAIL(buffer != NULL); wl_list_init(&buffer->link); @@ -885,10 +887,11 @@ handle_tbm_queue_buffer_attached(void *data, return; fail: - if (buffer->tbm_surface) - tbm_surface_destroy(buffer->tbm_surface); - - free(buffer); + if (buffer) { + if (buffer->tbm_surface) + tbm_surface_destroy(buffer->tbm_surface); + free(buffer); + } if (wl_buffer) wl_buffer_destroy(wl_buffer); -- 2.7.4