tbm_surface_internal_set_debug_data: adding check for existence of old data to avoid... 15/114515/2
authorAmit Agrawal <a.agrawal@samsung.com>
Mon, 13 Feb 2017 16:55:13 +0000 (22:25 +0530)
committerSooChan Lim <sc1.lim@samsung.com>
Tue, 14 Feb 2017 03:51:23 +0000 (19:51 -0800)
Change-Id: I3b18531d898d5cd756756c054db073bc581ec89e
Signed-off-by: Amit Agrawal <a.agrawal@samsung.com>
src/tbm_surface_internal.c

index 828538b..b7bb20a 100644 (file)
@@ -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;
                        }
                }
        }