Fixed coverity issue : 39056
[platform/core/connectivity/zigbee-manager.git] / zigbee-daemon / zigbee-interface / src / zigbee_service_dbus_interface_service.c
index 3327890..fc6943f 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <zblib_driver_service.h>
 
+/* LCOV_EXCL_START */
 static void *_service_interface_ref_zigbee_service(ZigBeeServiceInterface *service_interface)
 {
        ZigbeeObjectSkeleton *zigbee_object = NULL;
@@ -451,6 +452,9 @@ static void on_service_get_network_info_resp(ZigBeeServiceInterface *service_int
                payload->result, v_eui64, payload->node_id,
                payload->pan_id, payload->channel, payload->radio_tx_power);
 
+       if (v_eui64)
+               g_variant_unref(v_eui64);
+
        g_free(cb_data);
 }
 
@@ -784,6 +788,9 @@ static void on_service_get_mac_resp(ZigBeeServiceInterface *service_interface,
        zigbee_service_complete_get_mac(service_object, invocation, payload->result,
                v_eui64);
 
+       if (v_eui64)
+               g_variant_unref(v_eui64);
+
        g_free(cb_data);
 }
 
@@ -884,6 +891,11 @@ static void on_service_get_device_info_resp(ZigBeeServiceInterface *service_inte
        zigbee_service_complete_get_device_info(service_object, invocation,
                payload->result, variant);
 
+       if (variant)
+               g_variant_unref(variant);
+       if (builder)
+           g_variant_builder_unref(builder);
+
        g_free(cb_data);
 }
 
@@ -963,6 +975,9 @@ static void on_service_get_endpoint_list_resp(ZigBeeServiceInterface *service_in
        zigbee_service_complete_get_endpoint_list(service_object, invocation,
                payload->result, v_endpoints);
 
+       if (v_endpoints)
+               g_variant_unref(v_endpoints);
+
        g_free(cb_data);
 }
 
@@ -1062,6 +1077,11 @@ static void on_service_get_cluster_list_resp(ZigBeeServiceInterface *service_int
        zigbee_service_complete_get_cluster_list(service_object, invocation,
                payload->result, v_in_clusters, v_out_clusters);
 
+       if (v_in_clusters)
+               g_variant_unref(v_in_clusters);
+       if (v_out_clusters)
+               g_variant_unref(v_out_clusters);
+
        g_free(cb_data);
 }
 
@@ -1266,14 +1286,14 @@ void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface *
                        child_t->endpoints, child_t->endpoint_count, TRUE, NULL, NULL);
                if (NULL == v_eui64 || NULL == v_endpoints) {
                        Z_LOGE("Failed to create variant!");
-                       if (v_eui64)
-                               g_object_unref(v_eui64);
-                       if (v_endpoints)
-                               g_object_unref(v_endpoints);
                } else {
                        zigbee_service_emit_child_joined(service_object,
                                v_eui64, child_t->endpoint_count, v_endpoints, child_t->node_id);
                }
+               if (v_eui64)
+                       g_variant_unref(v_eui64);
+               if (v_endpoints)
+                       g_variant_unref(v_endpoints);
        }
        break;
        case ZBLIB_SERVICE_NOTI_CHILD_REJOINED: {
@@ -1286,6 +1306,8 @@ void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface *
                        Z_LOGE("Failed to create variant!");
                else
                        zigbee_service_emit_child_rejoined(service_object, v_eui64);
+               if (v_eui64)
+                       g_variant_unref(v_eui64);
        }
        break;
        case ZBLIB_SERVICE_NOTI_CHILD_LEFT: {
@@ -1299,6 +1321,7 @@ void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface *
                else {
                        zigbee_service_emit_child_left(service_object,
                                v_eui64, child_left_t->status);
+                       g_variant_unref(v_eui64);
                }
        }
        break;
@@ -1316,6 +1339,7 @@ void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface *
        /* ZigbeeService should be dereferenced */
        g_object_unref(service_object);
 }
+/* LCOV_EXCL_STOP */
 
 gboolean zigbee_service_dbus_interface_service_init(ZigBeeServiceInterface *service_interface,
        ZigbeeObjectSkeleton *zigbee_object)
@@ -1323,8 +1347,10 @@ gboolean zigbee_service_dbus_interface_service_init(ZigBeeServiceInterface *serv
        ZigbeeService *service_object;
 
        if (NULL == service_interface) {
+               /* LCOV_EXCL_START */
                Z_LOGE("service_interface is NULL");
                return FALSE;
+               /* LCOV_EXCL_STOP */
        }
 
        service_object = zigbee_service_skeleton_new();