Fix prevent CID 452988 ~ 452993
authorSangkwan Lee <skgood.lee@samsung.com>
Mon, 13 Jul 2015 09:22:30 +0000 (18:22 +0900)
committeryoungman <yman.jung@samsung.com>
Tue, 3 Nov 2015 11:08:19 +0000 (20:08 +0900)
Change-Id: Ib63ede6c2780daa44a781c62cee454c4bc637656
Signed-off-by: Sangkwan Lee <skgood.lee@samsung.com>
daemon/icd-dbus.c
lib/icl-repr.c

index a57cf612d054673433966ccdacda1756fa9626d8..30d5b27ef2b5102b68323cf744e96f84cd006e02 100644 (file)
@@ -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;
 }
 
index 9a76ef0d48719b647e7718c4e2912833add2e4ec..65af40e1fc9fe18cc70e7087e5072b7566350104 100644 (file)
@@ -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);