Skip to content

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

[GPU][COVERITY] Avoid temporary weak_ptr in try_get_cached_memory (#37921)

Sungeun Kim6e24110817f2
diff --git a/src/plugins/intel_gpu/src/plugin/remote_context.cpp b/src/plugins/intel_gpu/src/plugin/remote_context.cpp
index d183e080be8..bddee69f7e7 100644
--- a/src/plugins/intel_gpu/src/plugin/remote_context.cpp
+++ b/src/plugins/intel_gpu/src/plugin/remote_context.cpp
@@ -267,7 +267,8 @@ cldnn::memory::ptr RemoteContextImpl::try_get_cached_memory(size_t hash) {
if (!m_memory_cache.has(hash))
return nullptr;
- if (auto memory = m_memory_cache.get(hash).lock())
+ auto cached_memory = m_memory_cache.get(hash);
+ if (auto memory = cached_memory.lock())
return memory;
// The last tensor which wrapped that memory is gone, so the entry is erased instead of being kept as the most recently used one