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); } }