From 658e279eb98e54ba68d9ee699bf198b8d660cc3b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=91=D0=B0=D1=80?= =?utf8?q?=D0=B0=D0=BD=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2/AI=20Tools=20Lab=20/S?= =?utf8?q?RR/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Wed, 10 Jul 2019 13:05:18 +0300 Subject: [PATCH] [nnfw_api] Prevent memory leakage in `nnfw_session::prepare` method (#5602) Use `make_unique` to ensure memory is freed in case of exception. Signed-off-by: Sergei Barannikov --- runtimes/neurun/frontend/api/wrapper/nnfw_api.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtimes/neurun/frontend/api/wrapper/nnfw_api.cc b/runtimes/neurun/frontend/api/wrapper/nnfw_api.cc index be4266a..0d4b966 100644 --- a/runtimes/neurun/frontend/api/wrapper/nnfw_api.cc +++ b/runtimes/neurun/frontend/api/wrapper/nnfw_api.cc @@ -70,10 +70,9 @@ NNFW_STATUS nnfw_session::prepare() try { - auto compiler = new neurun::compiler::Compiler(_graph); + auto compiler = nnfw::cpp14::make_unique(_graph); compiler->compile(); compiler->release(_executor); - delete compiler; } catch (...) { -- 2.7.4