From 3d855f80f6f1bcb3b2cb3e025431242dc377ea34 Mon Sep 17 00:00:00 2001 From: lwk <1076278852@qq.com> Date: Fri, 25 Feb 2022 10:16:37 +0800 Subject: [PATCH] fix: memory leak Signed-off-by: lwk <1076278852@qq.com> --- oem_property/ohos/impl/dslm_ohos_verify.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/oem_property/ohos/impl/dslm_ohos_verify.c b/oem_property/ohos/impl/dslm_ohos_verify.c index de74fa6..da5d75e 100644 --- a/oem_property/ohos/impl/dslm_ohos_verify.c +++ b/oem_property/ohos/impl/dslm_ohos_verify.c @@ -343,7 +343,11 @@ static int32_t ParseNounceOfCertChain(const char *jsonBuffer, struct NounceOfCer static void FreeNounceOfCertChain(struct NounceOfCertChain *nounce) { - if (nounce != NULL && nounce->pbkInfoList != NULL) + if (nounce == NULL) + { + return; + } + if (nounce->pbkInfoList != NULL) { FREE(nounce->pbkInfoList); nounce->pbkInfoList = NULL; @@ -713,6 +717,7 @@ static int32_t verifySmallDslmCred(const DeviceIdentify *device, const DslmCredB (void)memset_s(credStr, credBuff->credLen + 1, 0, credBuff->credLen + 1); if (memcpy_s(credStr, credBuff->credLen + 1, credBuff->credVal, credBuff->credLen + 1) != EOK) { + FREE(credStr); return ERR_MEMORY_ERR; }