diff --git a/frameworks/core/src/common_event.cpp b/frameworks/core/src/common_event.cpp index 96275a2dc80ab6ffcc896356d2969e6300a0722c..8d2ad0eefd8956dde8fa9e8f58a7d09b249c7163 100644 --- a/frameworks/core/src/common_event.cpp +++ b/frameworks/core/src/common_event.cpp @@ -333,7 +333,7 @@ uint8_t CommonEvent::CreateCommonEventListener( return SUBSCRIBE_FAILED; } - sptr listener = new CommonEventListener(subscriber); + sptr listener = new (std::nothrow) CommonEventListener(subscriber); if (!listener) { EVENT_LOGE("the common event listener is null"); return SUBSCRIBE_FAILED; diff --git a/services/src/common_event_subscriber_manager.cpp b/services/src/common_event_subscriber_manager.cpp index ab7b7ffdfc6f4294d5dd185d71458cc8a7e5f23d..615afb8eabe1b6c21b661cd72cf1f3ebff5ebfef 100644 --- a/services/src/common_event_subscriber_manager.cpp +++ b/services/src/common_event_subscriber_manager.cpp @@ -26,7 +26,7 @@ constexpr int32_t LENGTH = 80; static constexpr int32_t SUBSCRIBE_EVENT_MAX_NUM = 512; CommonEventSubscriberManager::CommonEventSubscriberManager() - : death_(sptr(new SubscriberDeathRecipient())) + : death_(sptr(new (std::nothrow) SubscriberDeathRecipient())) { }