From: Boram Park Date: Fri, 23 Feb 2018 06:37:50 +0000 (+0900) Subject: buffer: not allow adding handler twice X-Git-Tag: submit/tizen/20180227.014049~40 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=39d1cdbb97a02a6008fe8e64a0a3de826c3c5684;p=platform%2Fcore%2Fuifw%2Flibtdm.git buffer: not allow adding handler twice Change-Id: I385a17820ff81f527ab21e0d01dbe07e274dace0 --- diff --git a/src/tdm_buffer.c b/src/tdm_buffer.c index 5d501b05..31e8c41f 100644 --- a/src/tdm_buffer.c +++ b/src/tdm_buffer.c @@ -120,7 +120,7 @@ tdm_buffer_add_release_handler(tbm_surface_h buffer, tdm_buffer_release_handler func, void *user_data) { tdm_buffer_info *buf_info; - tdm_buffer_func_info *func_info; + tdm_buffer_func_info *func_info = NULL; TDM_RETURN_VAL_IF_FAIL(buffer != NULL, TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); @@ -128,6 +128,13 @@ tdm_buffer_add_release_handler(tbm_surface_h buffer, buf_info = tdm_buffer_get_info(buffer); TDM_RETURN_VAL_IF_FAIL(buf_info != NULL, TDM_ERROR_OUT_OF_MEMORY); + LIST_FOR_EACH_ENTRY(func_info, &buf_info->release_funcs, link) { + if (func_info->release_func == func && func_info->user_data == user_data) { + TDM_ERR("can't add twice"); + return TDM_ERROR_BAD_REQUEST; + } + } + func_info = calloc(1, sizeof(tdm_buffer_func_info)); TDM_RETURN_VAL_IF_FAIL(func_info != NULL, TDM_ERROR_OUT_OF_MEMORY); @@ -240,6 +247,13 @@ tdm_buffer_add_destroy_handler(tbm_surface_h buffer, buf_info = tdm_buffer_get_info(buffer); TDM_RETURN_VAL_IF_FAIL(buf_info != NULL, TDM_ERROR_OUT_OF_MEMORY); + LIST_FOR_EACH_ENTRY(func_info, &buf_info->destroy_funcs, link) { + if (func_info->destroy_func == func && func_info->user_data == user_data) { + TDM_ERR("can't add twice"); + return TDM_ERROR_BAD_REQUEST; + } + } + func_info = calloc(1, sizeof(tdm_buffer_func_info)); TDM_RETURN_VAL_IF_FAIL(func_info != NULL, TDM_ERROR_OUT_OF_MEMORY);