From 6da260f74671d71a5c7a8a494f7ad72ef839f12b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=BD=99?= <1459392684@qq.com> Date: Tue, 9 Jul 2024 17:55:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=B8=85=E9=9B=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张余 <1459392684@qq.com> --- .../main/core/src/cert_manager_status.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/services/cert_manager_standard/cert_manager_engine/main/core/src/cert_manager_status.c b/services/cert_manager_standard/cert_manager_engine/main/core/src/cert_manager_status.c index b39be3b..3fa0255 100644 --- a/services/cert_manager_standard/cert_manager_engine/main/core/src/cert_manager_status.c +++ b/services/cert_manager_standard/cert_manager_engine/main/core/src/cert_manager_status.c @@ -228,6 +228,11 @@ static int DecodeStatus(RbTreeValue *value, const uint8_t *buf, uint32_t size) } cs->fileName = strdup((char *)s); + if (cs->fileName == NULL) { + CM_LOG_E("copy to cs failed"); + CMFree(cs); + return CMR_ERROR_MALLOC_FAIL; + } *value = cs; return CMR_OK; } @@ -575,6 +580,11 @@ static int32_t SetCertStatusNode(const struct CmContext *ctx, struct RbTree *tre cs->userId = ctx->userId; cs->uid = ctx->uid; cs->fileName = strdup(name); + if (cs->fileName == NULL) { + CM_LOG_E("Unable to allocate memory!!\n"); + CMFree(cs); + return CMR_ERROR_MALLOC_FAIL; + } cs->status = status; int rc = RbTreeInsert(tree, GetRbTreeKeyFromName(name), cs); if (rc != CMR_OK) { @@ -619,6 +629,11 @@ static int32_t SetUserCertStatusNode(const struct CertStatus *valInfo, struct Rb cStatus->userId = valInfo->userId; cStatus->uid = valInfo->uid; cStatus->fileName = strdup(name); + if (cStatus->fileName == NULL) { + CM_LOG_E("Unable to allocate memory!!\n"); + CMFree(cStatus); + return CMR_ERROR_MALLOC_FAIL; + } cStatus->status = status; int rc = RbTreeInsert(tree, GetRbTreeKey(store, name), cStatus); if (rc != CMR_OK) { -- Gitee