From c3e94a9aeb1de1c6e8a86298c95d125352513cb3 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Thu, 16 May 2024 07:07:58 +0000 Subject: [PATCH 01/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9interfaces/inner=5Fapi/?= =?UTF-8?q?syscap=5Finterface.c=E6=96=87=E4=BB=B6=EF=BC=8CpriSyscapArray?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E4=BD=BF=E7=94=A8=E5=90=8E=E7=AB=8B=E5=8D=B3?= =?UTF-8?q?=E8=B5=8B=E4=BA=88=E6=96=B0=E5=80=BC=20=E5=86=85=E5=AD=98priSys?= =?UTF-8?q?capArray=E5=8F=98=E9=87=8F=E4=BD=BF=E7=94=A8=E5=90=8E=E7=AB=8B?= =?UTF-8?q?=E5=8D=B3=E8=B5=8B=E4=BA=88=E6=96=B0=E5=80=BC=EF=BC=8C=E9=98=B2?= =?UTF-8?q?=E6=AD=A2=E4=B8=BA=E5=90=8E=E7=BB=AD=E4=BB=A3=E7=A0=81=E5=B8=A6?= =?UTF-8?q?=E6=9D=A5=E9=A3=8E=E9=99=A9=EF=BC=8C=E6=B6=88=E9=99=A4SecA=5FCB?= =?UTF-8?q?G=5FOH=5FC=5FCjsonManagerChecker=E4=BB=A3=E7=A0=81=E5=AE=89?= =?UTF-8?q?=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 | 1 + 1 file changed, 1 insertion(+) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index e7e32bb..b71b4fa 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -512,6 +512,7 @@ char *DecodeRpcidToStringFormat(const char *inputFile) } PartSysCapAndOutBuffer(freeAfterDecodeRpcidInfo, outBuffer, priSyscapArray, sysCapArray); + priSyscapArray = NULL; return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_MALLOC_PRISYSCAP_AFTER_DECODE_RPCID, outBuffer); } -- Gitee From 099b6d10d2e6df9fa57618ac90bdf5edaffd68fe Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Fri, 17 May 2024 07:19:27 +0000 Subject: [PATCH 02/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9src/create=5Fpcid.c?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E6=B6=88=E9=99=A4=E4=B8=BB=E5=B9=B2?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=AE=89=E5=85=A8=E5=91=8A=E8=AD=A6=20?= =?UTF-8?q?=E6=8C=87=E9=92=88=E5=8F=98=E9=87=8FfreePcidInfo.priSyscapFull?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=90=8E=E8=B5=8B=E5=80=BC=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=EF=BC=8C=E6=B6=88=E9=99=A4G.VAR.08=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 --- src/create_pcid.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/create_pcid.c b/src/create_pcid.c index 5176caf..1ad5fc0 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -899,6 +899,7 @@ int32_t EncodePcidscToString(char *inputFile, char *outDirPath) } (void)memset_s(freePcidInfo.priSyscapFull, priSyscapCount * SINGLE_SYSCAP_LEN, 0, priSyscapCount * SINGLE_SYSCAP_LEN); + freePcidInfo.priSyscapFull = NULL; ret = CheckPrivateSyCap(freePcidInfo, privateSyscapLen, privateSyscap, ret); if (ret == -1) { -- Gitee From b3fbada11ef64a7353ca405b326e205a075f4148 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Fri, 17 May 2024 08:20:19 +0000 Subject: [PATCH 03/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9interfaces/inner=5Fapi/?= =?UTF-8?q?syscap=5Finterface.c=E6=96=87=E4=BB=B6=EF=BC=8C=E5=86=85?= =?UTF-8?q?=E5=AD=98=E5=8F=98=E9=87=8FoutputArray=E5=9C=A8=E5=86=85?= =?UTF-8?q?=E5=AD=98=E9=87=8A=E6=94=BE=E5=90=8E=E8=B5=8B=E5=80=BC=E7=A9=BA?= =?UTF-8?q?=E5=80=BC=20247=E8=A1=8C=E5=86=85=E5=AD=98=E5=8F=98=E9=87=8Fout?= =?UTF-8?q?putArray=E5=9C=A8=E5=86=85=E5=AD=98=E9=87=8A=E6=94=BE=E5=90=8E?= =?UTF-8?q?=E8=B5=8B=E5=80=BC=E7=A9=BA=E5=80=BC?= 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 | 1 + 1 file changed, 1 insertion(+) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index b71b4fa..6274624 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -246,6 +246,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; -- Gitee From 02a587e086c45fb2313eb3036e341edd43137ab0 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Sat, 18 May 2024 01:48:43 +0000 Subject: [PATCH 04/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9src/create=5Fpcid.c?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E6=B6=88=E9=99=A4=E4=B8=BB=E5=B9=B2?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=AE=89=E5=85=A8=E5=91=8A=E8=AD=A6=20506?= =?UTF-8?q?=E8=A1=8CfreePcidJsonInfo=E5=BC=82=E5=B8=B8=E5=90=8EfreePcidJso?= =?UTF-8?q?nInfo.sysCapObj=20=E5=8F=98=E9=87=8F=E9=87=8D=E6=96=B0=E8=B5=8B?= =?UTF-8?q?=E5=80=BC=E4=B8=BA0=EF=BC=8C=E9=98=B2=E6=AD=A2=E5=86=85?= =?UTF-8?q?=E5=AD=98=E8=B5=84=E6=BA=90=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tongkai0808fh --- src/create_pcid.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/create_pcid.c b/src/create_pcid.c index 1ad5fc0..8d46f3c 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -504,6 +504,7 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) freePcidJsonInfo.sysCapObj = cJSON_CreateObject(); ret = CheckSysCapObj(freePcidJsonInfo, pcidMain, contextBufLen, ret); if (freePcidJsonInfo.flag == -1) { + freePcidJsonInfo.sysCapObj = NULL; return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_CONTEXT_OUT, ret); } -- Gitee From 00405cac9a1b4af3185533bd1ad9a7096758c1ee Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Sat, 18 May 2024 02:25:05 +0000 Subject: [PATCH 05/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9src/syscap=5Ftool.c?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E6=B6=88=E9=99=A4=E4=B8=BB=E5=B9=B2?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=AE=89=E5=85=A8=E5=91=8A=E8=AD=A6=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96502=E8=A1=8C=E6=8C=87=E9=92=88=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E7=A9=BA=E5=88=A4=E6=96=AD=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E6=B6=88=E9=99=A4=E4=B8=BB=E5=B9=B2=E4=BB=A3=E7=A0=81=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E6=BD=9C=E5=9C=A8=E7=9A=84=E5=86=85=E5=AD=98=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=B3=84=E6=BC=8F=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 --- src/syscap_tool.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/syscap_tool.c b/src/syscap_tool.c index e7b1314..2c115c8 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -499,10 +499,15 @@ int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath) char *CopyInputString(const char *inputString) { - if (inputString == NULL || *inputString == '\0') { - PRINT_ERR("inputString is null or empty.\n"); + if (inputString == NULL) { + PRINT_ERR("inputString is null.\n"); return NULL; } + if (*inputString == '\0') { + PRINT_ERR("inputString is empty.\n"); + inputString == NULL; + return NULL; + }} size_t inputLen = strlen(inputString); if (inputLen > STRING_FORMAT_LEN_MAX) { PRINT_ERR("input string too long(%zu).\n", inputLen); -- Gitee From 98786eb1bccb95fdf65eaebb30a49d01c161c8e4 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Sat, 18 May 2024 02:34:31 +0000 Subject: [PATCH 06/26] update src/syscap_tool.c. Signed-off-by: tongkai0808fh --- src/syscap_tool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syscap_tool.c b/src/syscap_tool.c index 2c115c8..5f01dcf 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -507,7 +507,7 @@ char *CopyInputString(const char *inputString) PRINT_ERR("inputString is empty.\n"); inputString == NULL; return NULL; - }} + } size_t inputLen = strlen(inputString); if (inputLen > STRING_FORMAT_LEN_MAX) { PRINT_ERR("input string too long(%zu).\n", inputLen); -- Gitee From 8e5067a34023d6ef92396319fa4b9d951c77f5eb Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Sat, 18 May 2024 03:06:24 +0000 Subject: [PATCH 07/26] =?UTF-8?q?=E6=B6=88=E9=99=A4src/syscap=5Ftool.c?= =?UTF-8?q?=E8=AF=AD=E6=B3=95=E9=94=99=E8=AF=AF=20=E6=B6=88=E9=99=A4pr?= =?UTF-8?q?=E8=AF=AD=E6=B3=95=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tongkai0808fh --- src/syscap_tool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syscap_tool.c b/src/syscap_tool.c index 5f01dcf..6b04e2c 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -505,7 +505,7 @@ char *CopyInputString(const char *inputString) } if (*inputString == '\0') { PRINT_ERR("inputString is empty.\n"); - inputString == NULL; + inputString = NULL; return NULL; } size_t inputLen = strlen(inputString); -- Gitee From d6f16eb96018bc0bffbf9c7b4d1699c4e494589a Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Sat, 18 May 2024 03:13:27 +0000 Subject: [PATCH 08/26] =?UTF-8?q?=E6=B6=88=E9=99=A4src/syscap=5Ftool.c?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=AE=89=E5=85=A8=E5=91=8A=E8=AD=A6=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=82=E5=B8=B8=E6=9D=A1=E4=BB=B6=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E8=AF=AD=E5=8F=A5=EF=BC=8C=E6=B6=88=E9=99=A4src/sysca?= =?UTF-8?q?p=5Ftool.c=E4=BB=A3=E7=A0=81=E5=AE=89=E5=85=A8=E5=91=8A?= =?UTF-8?q?=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tongkai0808fh --- src/syscap_tool.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/syscap_tool.c b/src/syscap_tool.c index 6b04e2c..3e27adb 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -474,13 +474,20 @@ int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath) // trans to string format freeAfterEncodeRpcidscInfo.sysCapDefine = CreateWholeSyscapJsonObj(); sysCapArray = cJSON_GetObjectItem(freeAfterEncodeRpcidscInfo.rpcidRoot, "syscap"); - if (sysCapArray == NULL || !cJSON_IsArray(sysCapArray)) { + if (sysCapArray == NULL) { + PRINT_ERR("syscap array is null. Input file: %s\n", inputFile); + return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, FREE_WHOLE_SYSCAP_AFTER_RPCIDSC, ret); + } + if (!cJSON_IsArray(sysCapArray)) { PRINT_ERR("Get syscap failed. Input file: %s\n", inputFile); + sysCapArray = NULL; return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, FREE_WHOLE_SYSCAP_AFTER_RPCIDSC, ret); } sysCapArraySize = cJSON_GetArraySize(sysCapArray); if (sysCapArraySize < 0) { PRINT_ERR("Get syscap size failed. Input file: %s\n", inputFile); + sysCapArray = NULL; + sysCapArraySize = NULL; return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, FREE_WHOLE_SYSCAP_AFTER_RPCIDSC, ret); } // malloc for save os syscap index @@ -492,6 +499,7 @@ int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath) ret = OutputSetMemAndPrintToFile(freeAfterEncodeRpcidscInfo, sysCapArraySize, sysCapArray, outDirPath); if (freeAfterEncodeRpcidscInfo.flag == 1) { + freeAfterEncodeRpcidscInfo.osSysCapIndex = NULL; return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, freeAfterEncodeRpcidscInfo.type, ret); } return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, FREE_OUTBUFFER_AFTER_RPCIDSC, ret); -- Gitee From 6d4946b97897f893d954752a1b8e415e0042fee3 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Sat, 18 May 2024 03:26:45 +0000 Subject: [PATCH 09/26] update src/syscap_tool.c. Signed-off-by: tongkai0808fh --- src/syscap_tool.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/syscap_tool.c b/src/syscap_tool.c index 3e27adb..b00d2b8 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -487,7 +487,6 @@ int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath) if (sysCapArraySize < 0) { PRINT_ERR("Get syscap size failed. Input file: %s\n", inputFile); sysCapArray = NULL; - sysCapArraySize = NULL; return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, FREE_WHOLE_SYSCAP_AFTER_RPCIDSC, ret); } // malloc for save os syscap index -- Gitee From 2f1ec66417c3c1223a742b86d8a964b2bbc086d7 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Sat, 18 May 2024 06:27:01 +0000 Subject: [PATCH 10/26] update src/create_pcid.c. Signed-off-by: tongkai0808fh --- src/create_pcid.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/create_pcid.c b/src/create_pcid.c index 8d46f3c..dcbb909 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -398,6 +398,7 @@ int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, size_t contextBufL PRINT_ERR("cJSON_AddItemToObject failed\n"); return GetPriSyscapResult(capVectorPtr, -1); } + capVectorPtr = NULL; return 0; } -- Gitee From fd59fe8e8b4fb3a1c53849324b8a910cad134691 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Sat, 18 May 2024 07:27:27 +0000 Subject: [PATCH 11/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9napi/napi=5Fquery=5Fsys?= =?UTF-8?q?cap.cpp=E6=96=87=E4=BB=B6=E4=B8=AD=E7=9A=84QuerySystemCapabilit?= =?UTF-8?q?y=E5=87=BD=E6=95=B0=EF=BC=8C=E6=B6=88=E9=99=A4=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E8=A1=8C=E6=95=B0=E8=BF=87=E9=95=BF=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96QuerySystemCapability=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=86=99=E6=B3=95=EF=BC=8C=E6=B6=88=E9=99=A4=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E8=A1=8C=E6=95=B0=E8=BF=87=E9=95=BF=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 --- napi/napi_query_syscap.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/napi/napi_query_syscap.cpp b/napi/napi_query_syscap.cpp index f01836f..df3ee13 100644 --- a/napi/napi_query_syscap.cpp +++ b/napi/napi_query_syscap.cpp @@ -149,16 +149,9 @@ FREE_PRIOUTPUT: return allSyscapBuffer; } -napi_value QuerySystemCapability(napi_env env, napi_callback_info info) +void HandleNapiValueType() { - GET_PARAMS(env, info, 1); - NAPI_ASSERT(env, argc <= 1, "too many parameters"); - napi_value result = nullptr; - - SystemCapabilityAsyncContext* asyncContext = new SystemCapabilityAsyncContext(); - asyncContext->env = env; - napi_valuetype valueType = napi_undefined; if (argc == 1) { napi_typeof(env, argv[0], &valueType); @@ -172,7 +165,16 @@ napi_value QuerySystemCapability(napi_env env, napi_callback_info info) } else { napi_get_undefined(env, &result); } +} + +napi_value QuerySystemCapability(napi_env env, napi_callback_info info) +{ + GET_PARAMS(env, info, 1); + NAPI_ASSERT(env, argc <= 1, "too many parameters"); + napi_value result = nullptr; + SystemCapabilityAsyncContext* asyncContext = new SystemCapabilityAsyncContext(); + HandleNapiValueType(); napi_value resource = nullptr; napi_create_string_utf8(env, "napi_value QuerySystemCapability", NAPI_AUTO_LENGTH, &resource); -- Gitee From 66b6009a8cb4a94dbbfc61b336405201c5df9b5a Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Sat, 18 May 2024 07:44:28 +0000 Subject: [PATCH 12/26] =?UTF-8?q?HandleNapiValueType=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tongkai0808fh --- napi/napi_query_syscap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napi/napi_query_syscap.cpp b/napi/napi_query_syscap.cpp index df3ee13..e1b191e 100644 --- a/napi/napi_query_syscap.cpp +++ b/napi/napi_query_syscap.cpp @@ -149,7 +149,7 @@ FREE_PRIOUTPUT: return allSyscapBuffer; } -void HandleNapiValueType() +void HandleNapiValueType(SystemCapabilityAsyncContext* asyncContext) { asyncContext->env = env; napi_valuetype valueType = napi_undefined; -- Gitee From 1b319e32d1bbe289b18eb72fceddbe46a75a0a16 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Sat, 18 May 2024 08:01:48 +0000 Subject: [PATCH 13/26] =?UTF-8?q?HandleNapiValueType=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=8A=A0=E5=85=A5napi=5Fenv=E5=8F=82=E6=95=B0=20HandleNapiValu?= =?UTF-8?q?eType=E5=87=BD=E6=95=B0=E5=8A=A0=E5=85=A5napi=5Fenv=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tongkai0808fh --- napi/napi_query_syscap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napi/napi_query_syscap.cpp b/napi/napi_query_syscap.cpp index e1b191e..f349a08 100644 --- a/napi/napi_query_syscap.cpp +++ b/napi/napi_query_syscap.cpp @@ -149,7 +149,7 @@ FREE_PRIOUTPUT: return allSyscapBuffer; } -void HandleNapiValueType(SystemCapabilityAsyncContext* asyncContext) +void HandleNapiValueType(SystemCapabilityAsyncContext* asyncContext, napi_env env) { asyncContext->env = env; napi_valuetype valueType = napi_undefined; -- Gitee From 6e84a5ef8d8d14b8db68f14b641de2f95ce97b1e Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Sat, 18 May 2024 08:14:34 +0000 Subject: [PATCH 14/26] update napi/napi_query_syscap.cpp. Signed-off-by: tongkai0808fh --- napi/napi_query_syscap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napi/napi_query_syscap.cpp b/napi/napi_query_syscap.cpp index f349a08..2e5e3ec 100644 --- a/napi/napi_query_syscap.cpp +++ b/napi/napi_query_syscap.cpp @@ -174,7 +174,7 @@ napi_value QuerySystemCapability(napi_env env, napi_callback_info info) napi_value result = nullptr; SystemCapabilityAsyncContext* asyncContext = new SystemCapabilityAsyncContext(); - HandleNapiValueType(); + HandleNapiValueType(asyncContext, env); napi_value resource = nullptr; napi_create_string_utf8(env, "napi_value QuerySystemCapability", NAPI_AUTO_LENGTH, &resource); -- Gitee From be5cb197e5f68a0336892fb5417f48052f1eab97 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Sat, 18 May 2024 08:34:38 +0000 Subject: [PATCH 15/26] update napi/napi_query_syscap.cpp. Signed-off-by: tongkai0808fh --- napi/napi_query_syscap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napi/napi_query_syscap.cpp b/napi/napi_query_syscap.cpp index 2e5e3ec..ddd6640 100644 --- a/napi/napi_query_syscap.cpp +++ b/napi/napi_query_syscap.cpp @@ -149,7 +149,7 @@ FREE_PRIOUTPUT: return allSyscapBuffer; } -void HandleNapiValueType(SystemCapabilityAsyncContext* asyncContext, napi_env env) +napi_value HandleNapiValueType(SystemCapabilityAsyncContext* asyncContext, napi_env env) { asyncContext->env = env; napi_valuetype valueType = napi_undefined; -- Gitee From 236dc9ed7cbcfe25b21131e079fdb62e9a459324 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Sat, 18 May 2024 09:06:21 +0000 Subject: [PATCH 16/26] =?UTF-8?q?HandleNapiValueType=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=82=E6=95=B0size=5Ft=20argc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tongkai0808fh --- napi/napi_query_syscap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/napi/napi_query_syscap.cpp b/napi/napi_query_syscap.cpp index ddd6640..b2f6c21 100644 --- a/napi/napi_query_syscap.cpp +++ b/napi/napi_query_syscap.cpp @@ -149,7 +149,7 @@ FREE_PRIOUTPUT: return allSyscapBuffer; } -napi_value HandleNapiValueType(SystemCapabilityAsyncContext* asyncContext, napi_env env) +napi_value HandleNapiValueType(SystemCapabilityAsyncContext* asyncContext, napi_env env, size_t argc) { asyncContext->env = env; napi_valuetype valueType = napi_undefined; @@ -174,7 +174,7 @@ napi_value QuerySystemCapability(napi_env env, napi_callback_info info) napi_value result = nullptr; SystemCapabilityAsyncContext* asyncContext = new SystemCapabilityAsyncContext(); - HandleNapiValueType(asyncContext, env); + HandleNapiValueType(asyncContext, env, argc); napi_value resource = nullptr; napi_create_string_utf8(env, "napi_value QuerySystemCapability", NAPI_AUTO_LENGTH, &resource); -- Gitee From ec6de0b73db0bade68ce7879ed4b512a0cf056e6 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Mon, 20 May 2024 02:31:03 +0000 Subject: [PATCH 17/26] update napi/napi_query_syscap.cpp. Signed-off-by: tongkai0808fh --- napi/napi_query_syscap.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/napi/napi_query_syscap.cpp b/napi/napi_query_syscap.cpp index b2f6c21..7d92176 100644 --- a/napi/napi_query_syscap.cpp +++ b/napi/napi_query_syscap.cpp @@ -149,7 +149,11 @@ FREE_PRIOUTPUT: return allSyscapBuffer; } -napi_value HandleNapiValueType(SystemCapabilityAsyncContext* asyncContext, napi_env env, size_t argc) +napi_value HandleNapiValueType(SystemCapabilityAsyncContext* asyncContext, + napi_env env, + size_t argc, + napi_value argv[argc], + napi_value result) { asyncContext->env = env; napi_valuetype valueType = napi_undefined; @@ -174,7 +178,7 @@ napi_value QuerySystemCapability(napi_env env, napi_callback_info info) napi_value result = nullptr; SystemCapabilityAsyncContext* asyncContext = new SystemCapabilityAsyncContext(); - HandleNapiValueType(asyncContext, env, argc); + HandleNapiValueType(asyncContext, env, argc, argv[argc], result); napi_value resource = nullptr; napi_create_string_utf8(env, "napi_value QuerySystemCapability", NAPI_AUTO_LENGTH, &resource); -- Gitee From 16db24f3bfe3d2a4c7f1463210b7a18a35e654f1 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Mon, 20 May 2024 02:49:27 +0000 Subject: [PATCH 18/26] =?UTF-8?q?=E5=9B=9E=E9=80=80napi/napi=5Fquery=5Fsys?= =?UTF-8?q?cap.cpp=E9=80=9A=E7=94=A8=E5=91=8A=E8=AD=A6=E6=95=B4=E6=94=B9?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=20=E5=9B=9E=E9=80=80napi/napi=5Fquery=5Fsysc?= =?UTF-8?q?ap.cpp=E9=80=9A=E7=94=A8=E5=91=8A=E8=AD=A6=E6=95=B4=E6=94=B9?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tongkai0808fh --- napi/napi_query_syscap.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/napi/napi_query_syscap.cpp b/napi/napi_query_syscap.cpp index 7d92176..6f75b2b 100644 --- a/napi/napi_query_syscap.cpp +++ b/napi/napi_query_syscap.cpp @@ -149,13 +149,16 @@ FREE_PRIOUTPUT: return allSyscapBuffer; } -napi_value HandleNapiValueType(SystemCapabilityAsyncContext* asyncContext, - napi_env env, - size_t argc, - napi_value argv[argc], - napi_value result) +napi_value QuerySystemCapability(napi_env env, napi_callback_info info) { + GET_PARAMS(env, info, 1); + NAPI_ASSERT(env, argc <= 1, "too many parameters"); + napi_value result = nullptr; + + SystemCapabilityAsyncContext* asyncContext = new SystemCapabilityAsyncContext(); + asyncContext->env = env; + napi_valuetype valueType = napi_undefined; if (argc == 1) { napi_typeof(env, argv[0], &valueType); @@ -169,16 +172,6 @@ napi_value HandleNapiValueType(SystemCapabilityAsyncContext* asyncContext, } else { napi_get_undefined(env, &result); } -} - -napi_value QuerySystemCapability(napi_env env, napi_callback_info info) -{ - GET_PARAMS(env, info, 1); - NAPI_ASSERT(env, argc <= 1, "too many parameters"); - napi_value result = nullptr; - - SystemCapabilityAsyncContext* asyncContext = new SystemCapabilityAsyncContext(); - HandleNapiValueType(asyncContext, env, argc, argv[argc], result); napi_value resource = nullptr; napi_create_string_utf8(env, "napi_value QuerySystemCapability", NAPI_AUTO_LENGTH, &resource); -- Gitee From 16830ed9eceb306ea81d5304b1241aa015cb0401 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Mon, 20 May 2024 09:29:49 +0000 Subject: [PATCH 19/26] update interfaces/inner_api/syscap_interface.c. Signed-off-by: tongkai0808fh --- interfaces/inner_api/syscap_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index 6274624..cdd35e7 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -527,7 +527,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); -- Gitee From 393fcdfdfb82b73ffa3820c425e3afc152edcb60 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Tue, 21 May 2024 02:34:32 +0000 Subject: [PATCH 20/26] =?UTF-8?q?update=20interfaces/inner=5Fapi/syscap=5F?= =?UTF-8?q?interface.c=EF=BC=8C=E5=88=A0=E5=8E=BB249=E8=A1=8CoutputArray?= =?UTF-8?q?=E7=BD=AE=E7=A9=BA=E8=AF=AD=E5=8F=A5?= 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 | 1 - 1 file changed, 1 deletion(-) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index cdd35e7..f5f224c 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -246,7 +246,6 @@ 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; -- Gitee From 29edaba5edae52ddb7ea29105a652faf45a889ba Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Tue, 21 May 2024 02:36:31 +0000 Subject: [PATCH 21/26] =?UTF-8?q?update=20src/create=5Fpcid.c=EF=BC=8C?= =?UTF-8?q?=E5=88=A0=E5=8E=BB401=E8=A1=8CcapVectorPtr=E7=BD=AE=E7=A9=BA?= =?UTF-8?q?=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tongkai0808fh --- src/create_pcid.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/create_pcid.c b/src/create_pcid.c index dcbb909..8d46f3c 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -398,7 +398,6 @@ int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, size_t contextBufL PRINT_ERR("cJSON_AddItemToObject failed\n"); return GetPriSyscapResult(capVectorPtr, -1); } - capVectorPtr = NULL; return 0; } -- Gitee From 8a78326ec4fb36568ee21ae9f188af92bf48d556 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Wed, 22 May 2024 08:26:21 +0000 Subject: [PATCH 22/26] =?UTF-8?q?=E5=9B=9E=E9=80=80src/syscap=5Ftool.c?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BF=AE=E6=94=B9=20=E5=9B=9E=E9=80=80src/sy?= =?UTF-8?q?scap=5Ftool.c=E6=96=87=E4=BB=B6=E4=BF=AE=E6=94=B9=EF=BC=8C?= =?UTF-8?q?=E5=AE=9A=E4=BD=8Dtdd=E6=B5=8B=E8=AF=95=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tongkai0808fh --- src/syscap_tool.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/syscap_tool.c b/src/syscap_tool.c index b00d2b8..e7b1314 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -474,19 +474,13 @@ int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath) // trans to string format freeAfterEncodeRpcidscInfo.sysCapDefine = CreateWholeSyscapJsonObj(); sysCapArray = cJSON_GetObjectItem(freeAfterEncodeRpcidscInfo.rpcidRoot, "syscap"); - if (sysCapArray == NULL) { - PRINT_ERR("syscap array is null. Input file: %s\n", inputFile); - return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, FREE_WHOLE_SYSCAP_AFTER_RPCIDSC, ret); - } - if (!cJSON_IsArray(sysCapArray)) { + if (sysCapArray == NULL || !cJSON_IsArray(sysCapArray)) { PRINT_ERR("Get syscap failed. Input file: %s\n", inputFile); - sysCapArray = NULL; return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, FREE_WHOLE_SYSCAP_AFTER_RPCIDSC, ret); } sysCapArraySize = cJSON_GetArraySize(sysCapArray); if (sysCapArraySize < 0) { PRINT_ERR("Get syscap size failed. Input file: %s\n", inputFile); - sysCapArray = NULL; return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, FREE_WHOLE_SYSCAP_AFTER_RPCIDSC, ret); } // malloc for save os syscap index @@ -498,7 +492,6 @@ int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath) ret = OutputSetMemAndPrintToFile(freeAfterEncodeRpcidscInfo, sysCapArraySize, sysCapArray, outDirPath); if (freeAfterEncodeRpcidscInfo.flag == 1) { - freeAfterEncodeRpcidscInfo.osSysCapIndex = NULL; return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, freeAfterEncodeRpcidscInfo.type, ret); } return FreeAfterEncodeRpcidsc(freeAfterEncodeRpcidscInfo, FREE_OUTBUFFER_AFTER_RPCIDSC, ret); @@ -506,13 +499,8 @@ int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath) char *CopyInputString(const char *inputString) { - if (inputString == NULL) { - PRINT_ERR("inputString is null.\n"); - return NULL; - } - if (*inputString == '\0') { - PRINT_ERR("inputString is empty.\n"); - inputString = NULL; + if (inputString == NULL || *inputString == '\0') { + PRINT_ERR("inputString is null or empty.\n"); return NULL; } size_t inputLen = strlen(inputString); -- Gitee From bb592119b82bb9deed85b26d81ce385d05bdc176 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Thu, 23 May 2024 02:04:22 +0000 Subject: [PATCH 23/26] =?UTF-8?q?=E5=9B=9E=E9=80=80src/create=5Fpcid.c?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=8C=E8=A7=A3=E5=86=B3pcid=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=9C=89=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tongkai0808fh --- src/create_pcid.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/create_pcid.c b/src/create_pcid.c index 8d46f3c..2548ea4 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -504,7 +504,6 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) freePcidJsonInfo.sysCapObj = cJSON_CreateObject(); ret = CheckSysCapObj(freePcidJsonInfo, pcidMain, contextBufLen, ret); if (freePcidJsonInfo.flag == -1) { - freePcidJsonInfo.sysCapObj = NULL; return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_CONTEXT_OUT, ret); } @@ -900,7 +899,7 @@ int32_t EncodePcidscToString(char *inputFile, char *outDirPath) } (void)memset_s(freePcidInfo.priSyscapFull, priSyscapCount * SINGLE_SYSCAP_LEN, 0, priSyscapCount * SINGLE_SYSCAP_LEN); - freePcidInfo.priSyscapFull = NULL; + // freePcidInfo.priSyscapFull = NULL; ret = CheckPrivateSyCap(freePcidInfo, privateSyscapLen, privateSyscap, ret); if (ret == -1) { -- Gitee From 6006961b75f3a6fdba9985e6ff5b39c573a2c969 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Thu, 23 May 2024 02:48:59 +0000 Subject: [PATCH 24/26] =?UTF-8?q?=E5=88=A0=E9=99=A4src/create=5Fpcid.c?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tongkai0808fh --- src/create_pcid.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/create_pcid.c b/src/create_pcid.c index 2548ea4..5176caf 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -899,7 +899,6 @@ int32_t EncodePcidscToString(char *inputFile, char *outDirPath) } (void)memset_s(freePcidInfo.priSyscapFull, priSyscapCount * SINGLE_SYSCAP_LEN, 0, priSyscapCount * SINGLE_SYSCAP_LEN); - // freePcidInfo.priSyscapFull = NULL; ret = CheckPrivateSyCap(freePcidInfo, privateSyscapLen, privateSyscap, ret); if (ret == -1) { -- Gitee From a67a22265f7b37f77a168f4ea236a9f6401ebf78 Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Thu, 23 May 2024 11:08:44 +0000 Subject: [PATCH 25/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9interfaces/inner=5Fapi/?= =?UTF-8?q?syscap=5Finterface.c=E7=9A=84EncodePrivateSyscap=E5=87=BD?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E5=8A=A0=E5=85=A5FreeContextBuffer(contextBu?= =?UTF-8?q?ffer)=E8=AF=AD=E5=8F=A5=20=E5=8A=A0=E5=85=A5FreeContextBuffer(c?= =?UTF-8?q?ontextBuffer)=E8=AF=AD=E5=8F=A5=EF=BC=8C=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=87=E7=BC=93=E5=AD=98?= 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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index f5f224c..45a89b9 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; } @@ -510,6 +513,7 @@ char *DecodeRpcidToStringFormat(const char *inputFile) return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_MALLOC_OSSYSCAP_AFTER_DECODE_RPCID, outBuffer); } + priSyscapArray = NULL; PartSysCapAndOutBuffer(freeAfterDecodeRpcidInfo, outBuffer, priSyscapArray, sysCapArray); priSyscapArray = NULL; -- Gitee From 63b2d93696a21e4779a2dc8cba62e2d8b7e6864f Mon Sep 17 00:00:00 2001 From: tongkai0808fh Date: Thu, 23 May 2024 11:15:59 +0000 Subject: [PATCH 26/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9src/create=5Fpcid.c?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E5=9C=A8GetOsSyscap=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E4=B8=AD=E5=8A=A0=E5=85=A5cJSON=5FDelete(capVectorPtr?= =?UTF-8?q?);=20=E5=9C=A8GetOsSyscap=E5=87=BD=E6=95=B0=E4=B8=AD=E5=8A=A0?= =?UTF-8?q?=E5=85=A5cJSON=5FDelete(capVectorPtr);=EF=BC=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4capVectorPtr=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tongkai0808fh --- src/create_pcid.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/create_pcid.c b/src/create_pcid.c index 5176caf..6f9a373 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -332,6 +332,7 @@ int32_t GetOsSyscap(PCIDMain *pcidMain, cJSON *sysCapObject) } if (!cJSON_AddItemToArray(capVectorPtr, cJSON_CreateString(g_arraySyscap[j].str))) { printf("cJSON_AddItemToArray or cJSON_CreateString failed\n"); + cJSON_Delete(capVectorPtr); return -1; } } @@ -339,9 +340,11 @@ int32_t GetOsSyscap(PCIDMain *pcidMain, cJSON *sysCapObject) if (!cJSON_AddItemToObject(sysCapObject, "os", capVectorPtr)) { PRINT_ERR("cJSON_AddItemToObject failed\n"); + cJSON_Delete(capVectorPtr); return -1; } + cJSON_Delete(capVectorPtr); return 0; } -- Gitee