diff --git a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp index 77ae69fd5fbd2bf5c45d515e7c544fe63114e3fb..52b9ac4e372ee504d1e01833ab53250f0d2e171e 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp @@ -789,6 +789,7 @@ ErrCode BundleMgrHost::HandleGetApplicationInfos(MessageParcel &data, MessagePar int userId = data.ReadInt32(); std::vector infos; bool ret = GetApplicationInfos(flag, userId, infos); + size_t vectorSize = infos.size(); if (!reply.WriteBool(ret)) { APP_LOGE("write failed"); return ERR_APPEXECFWK_PARCEL_ERROR; @@ -799,7 +800,7 @@ ErrCode BundleMgrHost::HandleGetApplicationInfos(MessageParcel &data, MessagePar return ERR_APPEXECFWK_PARCEL_ERROR; } } - APP_LOGI_NOFUNC("GetApplicationInfos bundles:%{public}zu, size:%{public}zu", infos.size(), reply.GetRawDataSize()); + APP_LOGI_NOFUNC("GetApplicationInfos bundles:%{public}zu, size:%{public}zu", vectorSize, reply.GetRawDataSize()); return ERR_OK; } @@ -810,6 +811,7 @@ ErrCode BundleMgrHost::HandleGetApplicationInfosWithIntFlags(MessageParcel &data int userId = data.ReadInt32(); std::vector infos; bool ret = GetApplicationInfos(flags, userId, infos); + size_t vectorSize = infos.size(); if (!reply.WriteBool(ret)) { APP_LOGE("write failed"); return ERR_APPEXECFWK_PARCEL_ERROR; @@ -820,7 +822,7 @@ ErrCode BundleMgrHost::HandleGetApplicationInfosWithIntFlags(MessageParcel &data return ERR_APPEXECFWK_PARCEL_ERROR; } } - APP_LOGI_NOFUNC("GetApplicationInfos bundles:%{public}zu, size:%{public}zu", infos.size(), reply.GetRawDataSize()); + APP_LOGI_NOFUNC("GetApplicationInfos bundles:%{public}zu, size:%{public}zu", vectorSize, reply.GetRawDataSize()); return ERR_OK; } @@ -831,6 +833,7 @@ ErrCode BundleMgrHost::HandleGetApplicationInfosWithIntFlagsV9(MessageParcel &da int32_t userId = data.ReadInt32(); std::vector infos; auto ret = GetApplicationInfosV9(flags, userId, infos); + size_t vectorSize = infos.size(); if (!reply.WriteInt32(ret)) { APP_LOGE("write failed"); return ERR_APPEXECFWK_PARCEL_ERROR; @@ -842,7 +845,7 @@ ErrCode BundleMgrHost::HandleGetApplicationInfosWithIntFlagsV9(MessageParcel &da } } APP_LOGI_NOFUNC("GetApplicationInfosV9 bundles:%{public}zu, size:%{public}zu", - infos.size(), reply.GetRawDataSize()); + vectorSize, reply.GetRawDataSize()); return ERR_OK; } @@ -1032,6 +1035,7 @@ ErrCode BundleMgrHost::HandleGetBundleInfos(MessageParcel &data, MessageParcel & std::vector infos; bool ret = GetBundleInfos(flag, infos, userId); + size_t vectorSize = infos.size(); if (!reply.WriteBool(ret)) { APP_LOGE("write failed"); return ERR_APPEXECFWK_PARCEL_ERROR; @@ -1043,7 +1047,7 @@ ErrCode BundleMgrHost::HandleGetBundleInfos(MessageParcel &data, MessageParcel & return ERR_APPEXECFWK_PARCEL_ERROR; } } - APP_LOGI("bundles %{public}zu, size %{public}zu", infos.size(), reply.GetRawDataSize()); + APP_LOGI("bundles %{public}zu, size %{public}zu", vectorSize, reply.GetRawDataSize()); return ERR_OK; } @@ -1055,6 +1059,7 @@ ErrCode BundleMgrHost::HandleGetBundleInfosWithIntFlags(MessageParcel &data, Mes std::vector infos; bool ret = GetBundleInfos(flags, infos, userId); + size_t vectorSize = infos.size(); if (!reply.WriteBool(ret)) { APP_LOGE("write failed"); return ERR_APPEXECFWK_PARCEL_ERROR; @@ -1066,7 +1071,7 @@ ErrCode BundleMgrHost::HandleGetBundleInfosWithIntFlags(MessageParcel &data, Mes return ERR_APPEXECFWK_PARCEL_ERROR; } } - APP_LOGI("bundles %{public}zu, size %{public}zu", infos.size(), reply.GetRawDataSize()); + APP_LOGI("bundles %{public}zu, size %{public}zu", vectorSize, reply.GetRawDataSize()); return ERR_OK; } @@ -1078,6 +1083,7 @@ ErrCode BundleMgrHost::HandleGetBundleInfosWithIntFlagsV9(MessageParcel &data, M std::vector infos; auto ret = GetBundleInfosV9(flags, infos, userId); + size_t vectorSize = infos.size(); if (!reply.WriteInt32(ret)) { APP_LOGE("write failed"); return ERR_APPEXECFWK_PARCEL_ERROR; @@ -1088,7 +1094,7 @@ ErrCode BundleMgrHost::HandleGetBundleInfosWithIntFlagsV9(MessageParcel &data, M return ERR_APPEXECFWK_PARCEL_ERROR; } } - APP_LOGI("bundles %{public}zu, size %{public}zu", infos.size(), reply.GetRawDataSize()); + APP_LOGI("bundles %{public}zu, size %{public}zu", vectorSize, reply.GetRawDataSize()); return ERR_OK; } @@ -3132,6 +3138,8 @@ bool BundleMgrHost::WriteVectorToParcelIntelligent(std::vector &parcelableVec } } + std::vector().swap(parcelableVector); + size_t dataSize = tempParcel.GetDataSize(); if (!reply.WriteInt32(static_cast(dataSize))) { APP_LOGE("write WriteInt32 failed");