From b6ef70f3474e4441aceda5d481e219642ecb3705 Mon Sep 17 00:00:00 2001 From: yuefanhao <95063759+yuefanhao@users.noreply.github.com> Date: Sat, 11 Nov 2023 02:04:45 +0800 Subject: [PATCH] fixed memory leak --- src/super_point.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/super_point.cpp b/src/super_point.cpp index f205a3b..63815a4 100644 --- a/src/super_point.cpp +++ b/src/super_point.cpp @@ -351,9 +351,16 @@ bool SuperPoint::deserialize_engine() { file.read(model_stream, size); file.close(); IRuntime *runtime = createInferRuntime(gLogger); - if (runtime == nullptr) return false; + if (runtime == nullptr) { + delete [] model_stream; + return false; + } engine_ = std::shared_ptr(runtime->deserializeCudaEngine(model_stream, size)); - if (engine_ == nullptr) return false; + if (engine_ == nullptr) { + delete [] model_stream; + return false; + } + delete [] model_stream; return true; } return false;