From 4be97c2066e739379cb86c19d2c673dba9b3976d Mon Sep 17 00:00:00 2001 From: Inki Dae Date: Tue, 8 Oct 2024 11:36:20 +0900 Subject: [PATCH] auto_zoom: check nullptr correctly Check nullptr correctly for each node. This patch will fix a coverity issue, CID-1789481. Ps. I will post other patch later, which will hide relevant exception code into task manger. Change-Id: I077269a73b4f03b5fbe66541e9705d5a92013085 Signed-off-by: Inki Dae --- services/auto_zoom/src/AutoZoom.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/services/auto_zoom/src/AutoZoom.cpp b/services/auto_zoom/src/AutoZoom.cpp index 7373175..729c767 100644 --- a/services/auto_zoom/src/AutoZoom.cpp +++ b/services/auto_zoom/src/AutoZoom.cpp @@ -114,13 +114,22 @@ AutoZoom::AutoZoom() _taskManager = make_unique(); auto face_detection_node = _taskManager->requestNewNode(NodeType::INFERENCE, "face_detection"); + if (dynamic_cast(face_detection_node) == nullptr) + throw InvalidOperation("Invalid inference node."); + dynamic_cast(face_detection_node)->setInferenceTask(factory->createFaceDetection()); auto bridge_node = _taskManager->requestNewNode(NodeType::BRIDGE, "bridge_node"); - bridge_node->addDependency(face_detection_node); + if (dynamic_cast(bridge_node) == nullptr) + throw InvalidOperation("Invalid bridge node."); + dynamic_cast(bridge_node)->setCb(BridgeNodeCallback); + bridge_node->addDependency(face_detection_node); auto face_recognition_node = _taskManager->requestNewNode(NodeType::INFERENCE, "face_recognition_node"); + if (dynamic_cast(face_recognition_node) == nullptr) + throw InvalidOperation("Invalid inference node."); + dynamic_cast(face_recognition_node)->setInferenceTask(factory->createFaceRecognition()); face_recognition_node->addDependency(bridge_node); -- 2.34.1