From c4cc4baaeeaed4036dee353e5693ba1b7efd6719 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Fri, 24 May 2024 03:15:48 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E9=99=A4interfaces/inner=5Fapi/syscap?= =?UTF-8?q?=5Finterface.c=E6=96=87=E4=BB=B6=E7=9A=84=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E5=AE=89=E5=85=A8=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tongkai0808fh --- interfaces/inner_api/syscap_interface.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index f2f8738..00954b1 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -121,17 +121,20 @@ bool EncodePrivateSyscap(char **output, int *outputLen) if (bufferLen < (PCID_MAIN_BYTES + 1) || bufferLen > INT32_MAX) { PRINT_ERR("Parameter bufferLen out of range."); + FreeContextBuffer(contextBuffer); return false; } uint32_t priLen = bufferLen - PCID_MAIN_BYTES - 1; if ((int)priLen <= 0) { *outputLen = 0; + FreeContextBuffer(contextBuffer); return false; } outputStr = (char *)calloc(priLen, sizeof(char)); if (outputStr == NULL) { PRINT_ERR("malloc buffer failed, size = %u, errno = %d\n", priLen, errno); *outputLen = 0; + FreeContextBuffer(contextBuffer); return false; } @@ -246,6 +249,7 @@ bool DecodePrivateSyscap(char *input, char (**output)[SINGLE_SYSCAP_LEN], int *o *bufferPos = '\0'; if (sprintf_s(*outputArray, SINGLE_SYSCAP_LEN, "SystemCapability.%s", buffer) == -1) { free(outputArray); + outputArray = NULL; return false; } bufferPos = buffer; @@ -512,6 +516,7 @@ char *DecodeRpcidToStringFormat(const char *inputFile) } PartSysCapAndOutBuffer(freeAfterDecodeRpcidInfo, outBuffer, priSyscapArray, sysCapArray); + priSyscapArray = NULL; return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_MALLOC_PRISYSCAP_AFTER_DECODE_RPCID, outBuffer); } @@ -525,7 +530,7 @@ static int32_t CopySyscopToRet(struct PcidPriSyscapInfo *pcidPriSyscapInfo, cons break; } } - if(t == allSyscapNum){ + if (t == allSyscapNum) { return -1; } pcidPriSyscapInfo->ret = strcpy_s(tempSyscap, sizeof(char) * SINGLE_SYSCAP_LEN, g_arraySyscap[t].str);