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/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 40e3e6db0f0dd7ac58ced9c1462aa5f9a18977b4..dc555ec86a7e28896ca65f5f467e90b26f19c79f 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -537,6 +537,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 d555303b4d140f5ad7e8ebab36872e32a7ee86a4..7e9044d6952da043de0d5acc00bba3a8feaf7ad8 100644 --- a/services/ans/src/notification_preferences.cpp +++ b/services/ans/src/notification_preferences.cpp @@ -640,6 +640,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 474c99e092510c5e71d4ab157a7782041fec1a0d..2bd44392866c1d8879d1b64a28f40e94d2e71475 100644 --- a/services/distributed/src/soft_bus/distributed_publish_service.cpp +++ b/services/distributed/src/soft_bus/distributed_publish_service.cpp @@ -339,7 +339,8 @@ void DistributedService::RemoveNotifications(const std::shared_ptr& boxM std::string slotTypeString; while (slotTypesStream >> slotTypeString) { if (!slotTypeString.empty()) { - AnalyticsUtil::GetInstance().OperationalReporting(OPERATION_DELETE_BRANCH, std::stoi(slotTypeString)); + AnalyticsUtil::GetInstance().OperationalReporting( + OPERATION_DELETE_BRANCH, atoi(slotTypeString.c_str())); } } } else {