From: Amit Agrawal Date: Mon, 13 Feb 2017 16:55:13 +0000 (+0530) Subject: tbm_surface_internal_set_debug_data: adding check for existence of old data to avoid... X-Git-Tag: accepted/tizen/3.0/common/20170216.151517~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F15%2F114515%2F2;p=platform%2Fcore%2Fuifw%2Flibtbm.git tbm_surface_internal_set_debug_data: adding check for existence of old data to avoid crash Change-Id: I3b18531d898d5cd756756c054db073bc581ec89e Signed-off-by: Amit Agrawal --- diff --git a/src/tbm_surface_internal.c b/src/tbm_surface_internal.c index 828538b..b7bb20a 100644 --- a/src/tbm_surface_internal.c +++ b/src/tbm_surface_internal.c @@ -1355,19 +1355,21 @@ tbm_surface_internal_set_debug_data(tbm_surface_h surface, char *key, char *valu if (!LIST_IS_EMPTY(&surface->debug_data_list)) { LIST_FOR_EACH_ENTRY(old_data, &surface->debug_data_list, item_link) { - if (!strcmp(old_data->key, key)) { - if (old_data->value && value && !strncmp(old_data->value, value, strlen(old_data->value))) { - TBM_TRACE("tbm_surface(%p) Already exist key(%s) and value(%s)!\n", surface, key, value); - goto add_debug_key_list; + if (old_data) { + if (!strcmp(old_data->key, key)) { + if (old_data->value && value && !strncmp(old_data->value, value, strlen(old_data->value))) { + TBM_TRACE("tbm_surface(%p) Already exist key(%s) and value(%s)!\n", surface, key, value); + goto add_debug_key_list; + } + + if (old_data->value) + free(old_data->value); + + if (value) + old_data->value = strdup(value); + else + old_data->value = NULL; } - - if (old_data->value) - free(old_data->value); - - if (value) - old_data->value = strdup(value); - else - old_data->value = NULL; } } }