From 5407cfba347776eebdfe66a7c3d9ffee88ce7f77 Mon Sep 17 00:00:00 2001 From: Sangkwan Lee Date: Mon, 13 Jul 2015 18:22:30 +0900 Subject: [PATCH] Fix prevent CID 452988 ~ 452993 Change-Id: Ib63ede6c2780daa44a781c62cee454c4bc637656 Signed-off-by: Sangkwan Lee --- daemon/icd-dbus.c | 30 +++++++++++++++--------------- lib/icl-repr.c | 9 +-------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/daemon/icd-dbus.c b/daemon/icd-dbus.c index a57cf61..30d5b27 100644 --- a/daemon/icd-dbus.c +++ b/daemon/icd-dbus.c @@ -315,7 +315,20 @@ static int _icd_dbus_resource_list_append_handle(const gchar *sender, void *hand cur_bus = cur_bus->next; } - if (false == sender_exist) { + if (true == sender_exist) { + cur_hd = bus->hdlist; + while (cur_hd) { + rsrc_handle = cur_hd->data; + + if (rsrc_handle->handle == handle) { + ERR("resource handle(%u, %u) already exist", rsrc_handle->handle, + rsrc_handle->number); + _icd_dbus_client_list_unlock(); + return IOTCON_ERROR_ALREADY; + } + cur_hd = cur_hd->next; + } + } else { DBG("sender(%s) not exist. make new one.", sender); new_bus = calloc(1, sizeof(icd_dbus_client_s)); @@ -338,20 +351,6 @@ static int _icd_dbus_resource_list_append_handle(const gchar *sender, void *hand bus = new_bus; } - cur_hd = bus->hdlist; - while (cur_hd) { - rsrc_handle = cur_hd->data; - - if (rsrc_handle->handle == handle) { - ERR("resource handle(%u, %u) already exist", rsrc_handle->handle, - rsrc_handle->number); - _icd_dbus_client_list_unlock(); - return IOTCON_ERROR_ALREADY; - } - - cur_hd = cur_hd->next; - } - rsrc_handle = calloc(1, sizeof(icd_resource_handle_s)); if (NULL == rsrc_handle) { ERR("calloc(handle) Fail(%d)", errno); @@ -606,6 +605,7 @@ static gboolean _dbus_handle_observer_start(icDbus *object, ic_dbus_complete_observer_start(object, invocation, observe_h, ret); + /* observe_h will be freed in _dbus_handle_observer_stop() */ return TRUE; } diff --git a/lib/icl-repr.c b/lib/icl-repr.c index 9a76ef0..65af40e 100644 --- a/lib/icl-repr.c +++ b/lib/icl-repr.c @@ -747,7 +747,6 @@ static void _icl_repr_obj_clone(char *key, iotcon_value_h src_val, iotcon_repr_h { FN_CALL; int type, ret; - char *dup_key; iotcon_value_h value, copied_val; iotcon_list_h child_list, copied_list; iotcon_repr_h child_repr, copied_repr; @@ -765,13 +764,7 @@ static void _icl_repr_obj_clone(char *key, iotcon_value_h src_val, iotcon_repr_h return; } - dup_key = ic_utils_strdup(key); - if (NULL == dup_key) { - ERR("dupic_utils_strdup() Fail"); - return; - } - - icl_obj_set_value(dest_repr, dup_key, copied_val); + icl_obj_set_value(dest_repr, key, copied_val); break; case IOTCON_TYPE_LIST: ret = icl_value_get_list(src_val, &child_list); -- 2.7.4