OCT 1.修正新增内存泄漏

This commit is contained in:
dongwenze 2023-03-30 10:09:05 +08:00
parent ad3ee42e09
commit 760a6eb14a
3 changed files with 16 additions and 0 deletions

View File

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

View File

@ -21,6 +21,9 @@ TEST_SUITE("Crypto functions") {
for(int i = 0; i<outputSize; i++) {
CHECK_EQ(decode[i], pSrc[i]);
}
free((void *)encode);
free((void *)decode);
}
TEST_CASE("AES") {
@ -37,5 +40,8 @@ TEST_SUITE("Crypto functions") {
symmetric_decrypto(algoType, out, outputSize, &res, &resSize, key);
CHECK_NE(res, nullptr);
REQUIRE_MESSAGE((strlen(data) == resSize), "the decrypted message:", res);
free((void *)out);
free((void *)res);
}
}

View File

@ -37,6 +37,8 @@ TEST_SUITE("S2J_TEST") {
for(i = 0; i < strlen(origin_Server.msg.info); i++) {
CHECK_EQ(origin_Server.msg.info[i], testServer->child->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);
}
}