diff --git a/frameworks/ans/src/notification_icon_button.cpp b/frameworks/ans/src/notification_icon_button.cpp index 3a8a9db73c3e5ef2640a156b6854909146e9fae0..0c799fc439bc74dd99c7d5d76541d0941d047007 100644 --- a/frameworks/ans/src/notification_icon_button.cpp +++ b/frameworks/ans/src/notification_icon_button.cpp @@ -311,7 +311,7 @@ bool NotificationIconButton::ReadResourceFromParcel(Parcel &parcel, ANS_LOGE("Invalid input for button icons resource"); return false; } - resource->id = std::stoi(iconsResource[RESOURCE_ID_INDEX]); + resource->id = atoi(iconsResource[RESOURCE_ID_INDEX].c_str()); resourceObj = resource; return true; } diff --git a/frameworks/ans/src/notification_local_live_view_button.cpp b/frameworks/ans/src/notification_local_live_view_button.cpp index 2b96fc2b3ad055431fdebba3d4505ee1e5da02e1..31fbce6673ce5bce1832895d943cd59aef16615a 100644 --- a/frameworks/ans/src/notification_local_live_view_button.cpp +++ b/frameworks/ans/src/notification_local_live_view_button.cpp @@ -272,7 +272,7 @@ bool NotificationLocalLiveViewButton::ReadFromParcel(Parcel &parcel) ANS_LOGE("Invalid input for button icons resource"); return false; } - resource->id = std::stoi(iconsResource[RESOURCE_ID_INDEX]); + resource->id = atoi(iconsResource[RESOURCE_ID_INDEX].c_str()); buttonIconsResource_.emplace_back(resource); } diff --git a/frameworks/js/napi/src/subscribe/napi_subscribe.cpp b/frameworks/js/napi/src/subscribe/napi_subscribe.cpp index deb0ceec817d6cf022c945f3dc38383dc27256fd..15eaa90091a95f90970ca0f9f0b976e5d3c8fdca 100644 --- a/frameworks/js/napi/src/subscribe/napi_subscribe.cpp +++ b/frameworks/js/napi/src/subscribe/napi_subscribe.cpp @@ -40,6 +40,10 @@ void NapiDistributeOperationExecuteCallback(napi_env env, void *data) } sptr operationInfo = new (std::nothrow) NotificationOperationInfo(); + if (operationInfo == nullptr) { + ANS_LOGE("create operationInfo failed"); + return; + } operationInfo->SetHashCode(asyncCallbackInfo->hashCode); if (asyncCallbackInfo->operationInfo.withOperationInfo) { operationInfo->SetOperationType(OperationType::DISTRIBUTE_OPERATION_REPLY); diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 3238874c39d022fe01a1c734f873810c1c6ad8bc..4753a881f164192f580fcd133c87e66dbce15118 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -523,6 +523,14 @@ ErrCode AdvancedNotificationService::CancelAsBundle( { ANS_LOGD("%{public}s", __FUNCTION__); int32_t reason = NotificationConstant::APP_CANCEL_AS_BUNELE_REASON_DELETE; + if (bundleOption == nullptr) { + std::string message = "bundleOption is invalid"; + OHOS::Notification::HaMetaMessage haMetaMessage = HaMetaMessage(2, 0) + .ErrorCode(ERR_ANS_INVALID_PARAM).NotificationId(notificationId); + ReportDeleteFailedEventPush(haMetaMessage, reason, message); + ANS_LOGE("%{public}s", message.c_str()); + return ERR_ANS_INVALID_PARAM; + } bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); if (!isSubsystem && !AccessTokenHelper::IsSystemApp()) { std::string message = "not systemApp"; diff --git a/services/ans/src/notification_preferences.cpp b/services/ans/src/notification_preferences.cpp index cbd846d8b6b75e6945b17f133d868928579b1623..b4006a8874790266e5dce4c74492493c519926b1 100644 --- a/services/ans/src/notification_preferences.cpp +++ b/services/ans/src/notification_preferences.cpp @@ -634,6 +634,10 @@ ErrCode NotificationPreferences::UpdateDoNotDisturbProfiles(int32_t userId, int6 } sptr profile = new (std::nothrow) NotificationDoNotDisturbProfile(); + if (profile == nullptr) { + ANS_LOGE("profile is nullptr"); + return ERR_ANS_INVALID_PARAM; + } std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; if (preferencesInfo.GetDoNotDisturbProfiles(profileId, userId, profile)) { diff --git a/services/distributed/src/soft_bus/distributed_publish_service.cpp b/services/distributed/src/soft_bus/distributed_publish_service.cpp index 6b685d87d8281544b11a5229ace81eb49d3b165c..f30b82b65ca796729795639bce1d1f1e60998065 100644 --- a/services/distributed/src/soft_bus/distributed_publish_service.cpp +++ b/services/distributed/src/soft_bus/distributed_publish_service.cpp @@ -349,7 +349,7 @@ void DistributedService::RemoveNotifications(const std::shared_ptr& boxM std::string slotTypeString; while (slotTypesStream >> slotTypeString) { if (!slotTypeString.empty()) { - OperationalReporting(OPERATION_DELETE_BRANCH, std::stoi(slotTypeString)); + OperationalReporting(OPERATION_DELETE_BRANCH, atoi(slotTypeString.c_str())); } } } else {