Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[CPU] Fix Coverity remarks related to nullptr dereference and invalid iterator (#30423)

Arseniy Obolenskiy4e462d026de8
diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/causal_mask_preprocess_fusion.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/causal_mask_preprocess_fusion.cpp
index ab7b9ec7b40..402f4d8f180 100644
--- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/causal_mask_preprocess_fusion.cpp
+++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/causal_mask_preprocess_fusion.cpp
@@ -226,7 +226,14 @@ CausalMaskPreprocess::CausalMaskPreprocess() {
ov::intel_cpu::CausalMaskPreprocessNode::Config config;
config.type = "CausalMaskPreprocess";
- auto triu = ov::as_type_ptr<ov::opset1::Constant>(pattern_map.find(const_triu)->second.get_node_shared_ptr());
+ auto const_triu_it = pattern_map.find(const_triu);
+ if (const_triu_it == pattern_map.end()) {
+ return false;
+ }
+ auto triu = ov::as_type_ptr<ov::opset1::Constant>(const_triu_it->second.get_node_shared_ptr());
+ if (!triu) {
+ return false;
+ }
auto triu_shape = triu->get_output_shape(0);
if (triu_shape.size() != 4) {