task_manager: check if _nodes is empty or not 38/311038/1
authorInki Dae <inki.dae@samsung.com>
Mon, 13 May 2024 07:43:13 +0000 (16:43 +0900)
committerInki Dae <inki.dae@samsung.com>
Mon, 13 May 2024 07:43:13 +0000 (16:43 +0900)
Check if _nodes is empty or not in output(). To get the output result,
_nodes must not be empty. In addition, use _nodes.back() instead of
nodes[nodes.size() - 1] for cleanup.

Change-Id: I22a085578a2fcba36d97685434fd6188ece60b66
Signed-off-by: Inki Dae <inki.dae@samsung.com>
services/task_manager/src/TaskManager.cpp

index bd06436adc44476a16a6d14b4a8f6e46f8b7e720..0ac19608f11e2e72bd44f6ef75fec3159fb4add3 100644 (file)
@@ -153,7 +153,12 @@ void TaskManager::run()
 
 vector<shared_ptr<BaseResultType> > &TaskManager::output()
 {
-       auto lastNode = _nodes[_nodes.size() - 1];
+       if (_nodes.empty()) {
+               SINGLEO_LOGE("Node is not set");
+               throw InvalidOperation("Node is not set");
+       }
+
+       auto lastNode = _nodes.back();
 
        _results.clear();