summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/src/api_stub.cc9
-rw-r--r--installer/src/api_stub.cc9
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<pkgmgr_res_event_info*>(
- new rpc_port::PkgSignal::ExtraData);
- if (!info) {
+ pkgmgr_res_event_info* info;
+ try {
+ info = reinterpret_cast<pkgmgr_res_event_info*>(
+ 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) {