From 760a6eb14ae29b6f1ac1ec300c7c475cd0f95645 Mon Sep 17 00:00:00 2001 From: dongwenze Date: Thu, 30 Mar 2023 10:09:05 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=E4=BF=AE=E6=AD=A3=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/opendhcp183/query.cpp | 6 ++++++ unit_test/crypto/crypto_test.cpp | 6 ++++++ unit_test/s2j/s2j_test.cpp | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/srcs/opendhcp183/query.cpp b/srcs/opendhcp183/query.cpp index f75ecac..b95c5a3 100644 --- a/srcs/opendhcp183/query.cpp +++ b/srcs/opendhcp183/query.cpp @@ -92,6 +92,7 @@ static int dhcp_get_user_info(const char **pRsp, const char *pRequest) { if (pStrContent == nullptr) { sprintf(logBuff, "Request Json error %s", pRequest); logDHCPMess(logBuff, 1); + free((void *)pStrContent); return ERR_PROTO_DECODE; } @@ -106,6 +107,7 @@ static int dhcp_get_user_info(const char **pRsp, const char *pRequest) { pSchJson = proto_msg_validation(pStrContent, i.pSchJson, i.pErrMsg); if (pSchJson != nullptr && strlen(pSchJson) > 0) { *pRsp = pSchJson; + free((void *)pStrContent); return ERR_SUCCESS; } } @@ -380,6 +382,7 @@ static int add_dhcpd_rangeset(const char **pRsp, const char *pRequest) { if (pStrContent == nullptr) { sprintf(logBuff, "Request Json error %s", pRequest); logDHCPMess(logBuff, 1); + free((void *)pStrContent); return ERR_PROTO_DECODE; } @@ -394,6 +397,7 @@ static int add_dhcpd_rangeset(const char **pRsp, const char *pRequest) { pSchJson = proto_msg_validation(pStrContent, i.pSchJson, i.pErrMsg); if (pSchJson != nullptr && strlen(pSchJson) > 0) { *pRsp = pSchJson; + free((void *)pStrContent); return ERR_SUCCESS; } } @@ -496,6 +500,7 @@ static int delete_dhcpd_rangeset(const char **pRsp, const char *pRequest) { if (pStrContent == nullptr) { sprintf(logBuff, "Request Json error %s", pRequest); logDHCPMess(logBuff, 1); + free((void*)pStrContent); return ERR_PROTO_DECODE; } @@ -510,6 +515,7 @@ static int delete_dhcpd_rangeset(const char **pRsp, const char *pRequest) { pSchJson = proto_msg_validation(pStrContent, i.pSchJson, i.pErrMsg); if (pSchJson != nullptr && strlen(pSchJson) > 0) { *pRsp = pSchJson; + free((void*)pStrContent); return ERR_SUCCESS; } } diff --git a/unit_test/crypto/crypto_test.cpp b/unit_test/crypto/crypto_test.cpp index 6455b18..afbfae1 100644 --- a/unit_test/crypto/crypto_test.cpp +++ b/unit_test/crypto/crypto_test.cpp @@ -21,6 +21,9 @@ TEST_SUITE("Crypto functions") { for(int i = 0; ichild->next->next->child->valuestring[i]); } + + cJSON_Delete(testServer); } TEST_CASE("J2S") { @@ -50,5 +52,7 @@ TEST_SUITE("S2J_TEST") { s2j_struct_get_basic_element(pMsg, testInfo, string, info); CHECK_EQ(pServer->id, 3); + cJSON_Delete(testServer); + free(pServer); } }