From: Сергей Баранников/AI Tools Lab /SRR/Engineer/삼성전자 Date: Wed, 10 Jul 2019 10:05:18 +0000 (+0300) Subject: [nnfw_api] Prevent memory leakage in `nnfw_session::prepare` method (#5602) X-Git-Tag: submit/tizen/20190809.050447~566 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=658e279eb98e54ba68d9ee699bf198b8d660cc3b;p=platform%2Fcore%2Fml%2Fnnfw.git [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 --- 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 (...) {