From 638971d2863372b620f4521465fee0968bba8463 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Mon, 1 Jul 2024 09:53:18 +0900 Subject: Fix static analysis issues Change-Id: I28b5e004c229d4643612a6c1abedf4b260096ef5 Signed-off-by: Sangyoon Jang --- client/src/api_stub.cc | 9 +++++---- installer/src/api_stub.cc | 9 ++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/client/src/api_stub.cc b/client/src/api_stub.cc index 16b01ff..7547c96 100644 --- a/client/src/api_stub.cc +++ b/client/src/api_stub.cc @@ -2050,10 +2050,11 @@ API int pkgmgr_client_res_usr_uninstall(pkgmgr_client *pc, const char *pkgid, } API pkgmgr_res_event_info *pkgmgr_res_event_info_new() { - pkgmgr_res_event_info* info = - reinterpret_cast( - new rpc_port::PkgSignal::ExtraData); - if (!info) { + pkgmgr_res_event_info* info; + try { + info = reinterpret_cast( + new rpc_port::PkgSignal::ExtraData); + } catch (const std::bad_alloc& e) { _E("Out of memory"); return nullptr; } diff --git a/installer/src/api_stub.cc b/installer/src/api_stub.cc index 5932cf6..59d76d9 100644 --- a/installer/src/api_stub.cc +++ b/installer/src/api_stub.cc @@ -47,12 +47,15 @@ API pkgmgr_installer* pkgmgr_installer_new() { _E("pkgmgr_installer_new fail"); return nullptr; } - - return nullptr; } API pkgmgr_installer* pkgmgr_installer_offline_new() { - return new pkgmgr::installer::Control(true); + try { + return new pkgmgr::installer::Control(true); + } catch (...) { + _E("pkgmgr_installer_offline_new fail"); + return nullptr; + } } API int pkgmgr_installer_free(pkgmgr_installer* pi) { -- cgit v1.2.3