Modified for Svace Issue (MEMORY_LEAK.EX) 16/123616/1
authorSegwon <segwon.han@samsung.com>
Thu, 6 Apr 2017 08:35:52 +0000 (17:35 +0900)
committerSegwon <segwon.han@samsung.com>
Thu, 6 Apr 2017 08:36:34 +0000 (17:36 +0900)
Issue : Dynamically allocated objects were not freed from macro of "IF_FAIL_VOID_TAG".

Signed-off-by: Segwon <segwon.han@samsung.com>
Change-Id: I51462a54b8791da7549612d68ef4f507644903fd

daemon/ServiceManager.cpp
daemon/discovery_provider/IotconDiscoveryProvider.cpp
daemon/service_provider/RemoteAppControlServiceProvider.cpp

index 4a386c7..2009630 100755 (executable)
@@ -449,17 +449,19 @@ int conv::ServiceManager::registerDiscoveryInfo()
        iotcon_resource_types_add(resource_types, CONV_RESOURCE_TYPE_TIZEN_D2D_SERVICE);
 
        error = iotcon_resource_interfaces_create(&resource_ifaces);
-
-       IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "ri creation failed");
+       IF_FAIL_CATCH_TAG(error == IOTCON_ERROR_NONE, _E, "ri creation failed");
 
        iotcon_resource_interfaces_add(resource_ifaces, IOTCON_INTERFACE_DEFAULT);
 
        error = iotcon_resource_create(CONV_URI_TIZEN_D2D_SERVICE, resource_types, resource_ifaces, properties, iotcon_request_cb, this, &iotcon_resource);
-       IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "resource creation failed");
+       IF_FAIL_CATCH_TAG(error == IOTCON_ERROR_NONE, _E, "resource creation failed");
 
        _D("device info registered as resource");
+
+CATCH:
        iotcon_resource_types_destroy(resource_types);
        iotcon_resource_interfaces_destroy(resource_ifaces);
+       IF_FAIL_RETURN(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION);
 
        return CONV_ERROR_NONE;
 }
@@ -472,7 +474,6 @@ int conv::ServiceManager::unregisterDiscoveryInfo()
        IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "resource destroy failed");
        iotcon_resource = NULL;
 
-
        _D("device info unregistered");
        return CONV_ERROR_NONE;
 }
index 9326e63..4a77f3d 100755 (executable)
@@ -269,9 +269,9 @@ void conv::IotconDiscoveryProvider::__get_detail_info(iotcon_remote_resource_h r
        ret = iotcon_remote_resource_get(resource_clone, query, __on_received_detail_info, NULL);
        if (ret != IOTCON_ERROR_NONE) {
                _E("Failed[%d] to get remote resource query", ret);
-               iotcon_query_destroy(query);
-               return;
        }
+       iotcon_query_destroy(query);
+       return;
 }
 
 string conv::IotconDiscoveryProvider::__generate_discovery_key(char* uri_path, char* host_address)
index ba6777b..a4e5780 100755 (executable)
@@ -210,6 +210,9 @@ static void _app_control_cb(app_control_h request, app_control_h reply, app_cont
        _send_response(cb_info.request_handle, rep, IOTCON_RESPONSE_OK);
        _D("Response sent");
 
+       iotcon_attributes_destroy(attributes);
+       iotcon_representation_destroy(rep);
+
        bundle_free(p_bundle);
        bundle_free(p_bundle_request);
        app_control_cb_map.erase(find_iter);
@@ -653,19 +656,19 @@ int conv::RemoteAppControlServiceProvider::init()
                iotcon_resource_types_add(resource_types, __resourceType.c_str());
 
                error = iotcon_resource_interfaces_create(&resource_ifaces);
-
-               IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "ri creation failed");
+               IF_FAIL_CATCH_TAG(error == IOTCON_ERROR_NONE, _E, "ri creation failed");
 
                iotcon_resource_interfaces_add(resource_ifaces, IOTCON_INTERFACE_DEFAULT);
 
-
                error = iotcon_resource_create(CONV_URI_REMOTE_APP_CONTROL, resource_types, resource_ifaces, properties, __iotcon_request_cb, NULL, &iotcon_resource);
-               IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "resource creation failed");
+               IF_FAIL_CATCH_TAG(error == IOTCON_ERROR_NONE, _E, "resource creation failed");
 
+               _D("RemoteAppControlServiceProvider init done");
+CATCH:
                iotcon_resource_types_destroy(resource_types);
                iotcon_resource_interfaces_destroy(resource_ifaces);
+               IF_FAIL_RETURN(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION);
 
-               _D("RemoteAppControlServiceProvider init done");
        } else {
                _D("RemoteAppControlServiceProvider is already initiated");
        }
@@ -838,8 +841,7 @@ int conv::RemoteAppControlServiceProvider::startRequest(Request* requestObj)
        iotcon_resource_types_add(resource_types, svcInfo->iotconInfoObj.resourceType.c_str());
 
        error = iotcon_resource_interfaces_create(&resource_ifaces);
-
-       IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "ri creation failed");
+       IF_FAIL_CATCH_TAG(error == IOTCON_ERROR_NONE, _E, "ri creation failed");
 
        iotcon_resource_interfaces_add(resource_ifaces, IOTCON_INTERFACE_DEFAULT);
 
@@ -847,11 +849,12 @@ int conv::RemoteAppControlServiceProvider::startRequest(Request* requestObj)
                        &(svcInfo->iotconInfoObj.iotconResourceHandle));
 
        _D("remote resource created : %s, %s", svcInfo->iotconInfoObj.address.c_str(), svcInfo->iotconInfoObj.uri.c_str());
+       IF_FAIL_CATCH_TAG(error == IOTCON_ERROR_NONE, _E, "remote resource creation failed %s, %s", svcInfo->iotconInfoObj.address.c_str(), svcInfo->iotconInfoObj.uri.c_str());
 
-       IF_FAIL_RETURN_TAG(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION, _E, "remote resource creation failed %s, %s", svcInfo->iotconInfoObj.address.c_str(), svcInfo->iotconInfoObj.uri.c_str());
-
+CATCH:
        iotcon_resource_types_destroy(resource_types);
        iotcon_resource_interfaces_destroy(resource_ifaces);
+       IF_FAIL_RETURN(error == IOTCON_ERROR_NONE, CONV_ERROR_INVALID_OPERATION);
 
        //send message for access request
        iotcon_representation_h representation;