!330 增加return前内存释放

Merge pull request !330 from 张余/master
This commit is contained in:
openharmony_ci 2024-09-05 09:01:29 +00:00 committed by Gitee
commit 84405ef58d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 10 additions and 3 deletions

View File

@ -478,6 +478,7 @@ static int32_t CheckIsAuthorizedApp(const struct CMUri *uriObj)
uint32_t clientUid = 0;
if (CmIsNumeric(uriObj->clientApp, strlen(uriObj->clientApp) + 1, &clientUid) != CM_SUCCESS) {
CM_LOG_E("parse string to uint32 failed.");
CM_FREE_PTR(macByte.data);
return CMR_ERROR_INVALID_ARGUMENT;
}

View File

@ -232,6 +232,7 @@ static int32_t CheckAndGetStore(const struct CmContext *context, const struct Cm
uint32_t userId = 0;
if (CmIsNumeric(uriObj.user, strlen(uriObj.user) + 1, &userId) != CM_SUCCESS) {
CM_LOG_E("parse string to uint32 failed.");
(void)CertManagerFreeUri(&uriObj);
return CMR_ERROR_INVALID_ARGUMENT;
}
@ -731,6 +732,7 @@ static int32_t CmComparisonCallerIdWithUri(const struct CmContext *context,
uint32_t userId = 0;
if (CmIsNumeric(uriObj.user, strlen(uriObj.user) + 1, &userId) != CM_SUCCESS) {
CM_LOG_E("parse string to uint32 failed.");
(void)CertManagerFreeUri(&uriObj);
return CMR_ERROR_INVALID_ARGUMENT;
}
@ -742,6 +744,7 @@ static int32_t CmComparisonCallerIdWithUri(const struct CmContext *context,
uint32_t uid = 0;
if (CmIsNumeric(uriObj.app, strlen(uriObj.app) + 1, &uid) != CM_SUCCESS) {
CM_LOG_E("parse string to uint32 failed.");
(void)CertManagerFreeUri(&uriObj);
return CMR_ERROR_INVALID_ARGUMENT;
}

View File

@ -223,7 +223,8 @@ int32_t CmConstructContextFromUri(const char *certUri, struct CmContext *context
if (CmIsNumeric(cmUri.user, strlen(cmUri.user) + 1, &(context->userId)) != CM_SUCCESS ||
CmIsNumeric(cmUri.app, strlen(cmUri.app) + 1, &(context->uid)) != CM_SUCCESS) {
CM_LOG_E("parse string to uint32 failed.");
return CMR_ERROR_INVALID_ARGUMENT;
ret = CMR_ERROR_INVALID_ARGUMENT;
break;
}
if (snprintf_s(context->packageName, sizeof(context->packageName), sizeof(context->packageName) - 1, "%s",
@ -404,7 +405,7 @@ static int32_t UpdateUserCerts(uint32_t userId, const char *userIdPath)
/* Update certificate file */
if (CmIsNumeric(dire->d_name, strlen(dire->d_name) + 1, &uid) != CM_SUCCESS) {
CM_LOG_E("parse string to uint32 failed.");
return CMR_ERROR_INVALID_ARGUMENT;
continue;
}
ret = UpdateUserCert(userId, uid, (const char *)certFilePath->data);
@ -455,7 +456,7 @@ static int32_t UpdateAllUserCerts(void)
/* Updates all certificates for the specified user */
if (CmIsNumeric(dire->d_name, strlen(dire->d_name) + 1, &userId) != CM_SUCCESS) {
CM_LOG_E("parse string to uint32 failed.");
return CMR_ERROR_INVALID_ARGUMENT;
continue;
}
int32_t ret = UpdateUserCerts(userId, userIdPath);

View File

@ -552,6 +552,7 @@ int32_t CertManagerGetUidFromUri(const struct CmBlob *uri, uint32_t *uid)
if (CmIsNumeric(uriObj.app, strlen(uriObj.app) + 1, uid) != CM_SUCCESS) {
CM_LOG_E("parse string to uint32 failed.");
(void)CertManagerFreeUri(&uriObj);
return CMR_ERROR_INVALID_ARGUMENT;
}

View File

@ -321,6 +321,7 @@ static int32_t CmTraversalDir(const struct CmContext *context, const char *path,
if (CmIsNumeric(dire->d_name, strlen(dire->d_name) + 1, &uid) != CM_SUCCESS) {
CM_LOG_E("parse string to uint32 failed.");
closedir(dir);
return CMR_ERROR_INVALID_ARGUMENT;
}