From b3620b7e7703f8d5b38f29056ef00fd7d9157afb Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Fri, 15 Jul 2022 13:53:25 +0900 Subject: [PATCH] e_hwc_windows: fix leak of E_Hwc_Windows_Comp_Info there is leak of E_Hwc_Windows_Comp_Info when tbm_surface is null or tbm_surface_internal_add/set_user_data are failed. Change-Id: If8236a1ab70a064f34ba5bc9c39dd6c3998d5889 --- src/bin/e_hwc_windows.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/bin/e_hwc_windows.c b/src/bin/e_hwc_windows.c index e519ff6..dbf87d1 100644 --- a/src/bin/e_hwc_windows.c +++ b/src/bin/e_hwc_windows.c @@ -276,6 +276,8 @@ _e_hwc_windows_comp_info_get(tbm_surface_h tbm_surface) { E_Hwc_Windows_Comp_Info *comp_info = NULL; + if (!tbm_surface) return NULL; + tbm_surface_internal_get_user_data(tbm_surface, EHWS_BUFFER_COMP_INFO_KEY, (void**)&comp_info); @@ -288,13 +290,21 @@ _e_hwc_windows_comp_info_get(tbm_surface_h tbm_surface) e_hwc_presentation_callback_list_init(&comp_info->presentation_callbacks); e_comp_wl_tizen_hwc_feedback_list_init(&comp_info->feedback_list); - tbm_surface_internal_add_user_data(tbm_surface, EHWS_BUFFER_COMP_INFO_KEY, - _e_hwc_windows_comp_info_cb_tbm_surface_destroy); + if (!tbm_surface_internal_add_user_data(tbm_surface, EHWS_BUFFER_COMP_INFO_KEY, + _e_hwc_windows_comp_info_cb_tbm_surface_destroy)) + goto fail; - tbm_surface_internal_set_user_data(tbm_surface, EHWS_BUFFER_COMP_INFO_KEY, - comp_info); + if(!tbm_surface_internal_set_user_data(tbm_surface, EHWS_BUFFER_COMP_INFO_KEY, + comp_info)) + goto fail; return comp_info; + +fail: + if (comp_info) + free(comp_info); + + return NULL; } static void @@ -657,13 +667,16 @@ _e_hwc_windows_target_window_buffer_skip(E_Hwc *hwc) { hwc_window = (E_Hwc_Window *)hwc->root_target_hwc_window; - comp_info = _e_hwc_windows_comp_info_get(hwc_window->current.buffer.tsurface); - if (comp_info) + if (hwc_window->current.buffer.tsurface) { - e_hwc_window_presentation_time_feedback_take((E_Hwc_Window *)target_hwc_window, - &comp_info->presentation_container); - e_hwc_window_presentation_callback_take((E_Hwc_Window *)target_hwc_window, - &comp_info->presentation_callbacks); + comp_info = _e_hwc_windows_comp_info_get(hwc_window->current.buffer.tsurface); + if (comp_info) + { + e_hwc_window_presentation_time_feedback_take((E_Hwc_Window *)target_hwc_window, + &comp_info->presentation_container); + e_hwc_window_presentation_callback_take((E_Hwc_Window *)target_hwc_window, + &comp_info->presentation_callbacks); + } } e_hwc_window_queue_buffer_reference(&hwc_window->current.queue_buffer_ref, hwc_window->display.queue_buffer_ref.buffer); -- 2.7.4