diff --git a/framework/ndkimpl/data/udmf.cpp b/framework/ndkimpl/data/udmf.cpp index 9d4e1e8431326b0aa79f0b85803ab649858d2339..8554af1e4e2ae9a25032982b0b2860c706ea20f4 100644 --- a/framework/ndkimpl/data/udmf.cpp +++ b/framework/ndkimpl/data/udmf.cpp @@ -963,6 +963,10 @@ int OH_UdmfRecord_GetArrayBuffer(OH_UdmfRecord* record, const char* type, OH_Uds { unsigned int size = 0; unsigned char *entry; + if (buffer == nullptr) { + LOG_ERROR(UDMF_CAPI, "buffer is nullptr."); + return UDMF_E_INVALID_PARAM; + } int ret = OH_UdmfRecord_GetGeneralEntry(record, type, &entry, &size); if (ret != UDMF_E_OK) { LOG_ERROR(UDMF_CAPI, "OH_UdmfRecord_GetGeneralEntry ret: %{public}d.", ret); diff --git a/framework/ndkimpl/data/udmf_capi_common.h b/framework/ndkimpl/data/udmf_capi_common.h index d16733a900c221f10612af2d0333d216fd1c90c7..a0587db5f812f1163aaf4ccdde34bf8c8ebc1298 100644 --- a/framework/ndkimpl/data/udmf_capi_common.h +++ b/framework/ndkimpl/data/udmf_capi_common.h @@ -97,7 +97,7 @@ struct OH_UdmfRecord { unsigned int recordDataLen {0}; char **typesArray {nullptr}; unsigned int typesCount {0}; - char *lastType {nullptr}; + std::string lastType; std::mutex mutex; }; diff --git a/framework/ndkimpl/data/uds.cpp b/framework/ndkimpl/data/uds.cpp index 87c95ed1d9fd6def0d1ca911d2463f1f47c61bda..d09aa44605a2e864f4f1418ff94d9bcf282c6767 100644 --- a/framework/ndkimpl/data/uds.cpp +++ b/framework/ndkimpl/data/uds.cpp @@ -589,7 +589,9 @@ const char* OH_UdsContentForm_GetType(OH_UdsContentForm* pThis) int OH_UdsContentForm_GetThumbData(OH_UdsContentForm* pThis, unsigned char** thumbData, unsigned int* len) { - if (IsInvalidUdsObjectPtr(pThis, NdkStructId::UDS_CONTENT_FORM_STRUCT_ID)) { + if (thumbData == nullptr || len == nullptr || + IsInvalidUdsObjectPtr(pThis, NdkStructId::UDS_CONTENT_FORM_STRUCT_ID)) { + LOG_ERROR(UDMF_CAPI, "Param is invalid."); return UDMF_E_INVALID_PARAM; } return GetUdsUint8Value(pThis, THUMB_DATA, THUMB_DATA_LENGTH, thumbData, len); @@ -607,7 +609,8 @@ const char* OH_UdsContentForm_GetTitle(OH_UdsContentForm* pThis) int OH_UdsContentForm_GetAppIcon(OH_UdsContentForm* pThis, unsigned char** appIcon, unsigned int* len) { - if (IsInvalidUdsObjectPtr(pThis, NdkStructId::UDS_CONTENT_FORM_STRUCT_ID)) { + if (appIcon == nullptr || len == nullptr || IsInvalidUdsObjectPtr(pThis, NdkStructId::UDS_CONTENT_FORM_STRUCT_ID)) { + LOG_ERROR(UDMF_CAPI, "Param is invalid."); return UDMF_E_INVALID_PARAM; } return GetUdsUint8Value(pThis, APP_ICON, APP_ICON_LENGTH, appIcon, len);