From 782847018f97fad11be04121376bc0a01794f4c7 Mon Sep 17 00:00:00 2001 From: huangxin Date: Mon, 20 Feb 2023 17:23:21 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20=E4=BF=AE=E6=AD=A3=E4=B8=80=E5=A4=84?= =?UTF-8?q?cJSON=E8=A7=A3=E6=9E=90=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/libs/protocol/protocol.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/srcs/libs/protocol/protocol.c b/srcs/libs/protocol/protocol.c index 9ab740f..f8a3d24 100644 --- a/srcs/libs/protocol/protocol.c +++ b/srcs/libs/protocol/protocol.c @@ -36,7 +36,7 @@ const char *proto_decode_context(const char *pString, unsigned int *pVer, unsign cJSON *pCrypto = cJSON_GetObjectItem(pRoot, "cryptoType"); if (!pCrypto) { - cJSON_free(pRoot); + cJSON_Delete(pRoot); return NULL; } @@ -59,13 +59,13 @@ const char *proto_decode_context(const char *pString, unsigned int *pVer, unsign pMsgCtx = cJSON_GetObjectItem(pRoot, "msgContent"); if (!pMsgCtx) { - cJSON_free(pRoot); + cJSON_Delete(pRoot); return NULL; } switch (pCrypto->valueint) { case CRYPTO_NONE: - pMsgContent = strdup(cJSON_Print(pMsgCtx)); + pMsgContent = cJSON_Print(pMsgCtx); break; case CRYPTO_BASE64: pMsgContent = (char *)base64_decode(pMsgCtx->valuestring, (unsigned int *)&outSize); @@ -83,7 +83,7 @@ const char *proto_decode_context(const char *pString, unsigned int *pVer, unsign } else if (pCrypto->valueint == CRYPTO_3DES) { cryptoType = DES3_ECB_PKCS7PADDING; } else { - cJSON_free(pRoot); + cJSON_Delete(pRoot); return NULL; } @@ -95,7 +95,7 @@ const char *proto_decode_context(const char *pString, unsigned int *pVer, unsign if (pMsgContent) { free(pMsgContent); } - cJSON_free(pRoot); + cJSON_Delete(pRoot); return NULL; } else { pMsgContent[decodeSize] = 0; @@ -104,7 +104,7 @@ const char *proto_decode_context(const char *pString, unsigned int *pVer, unsign } break; } - cJSON_free(pRoot); + cJSON_Delete(pRoot); return pMsgContent; } @@ -200,7 +200,7 @@ const char *proto_create_new(cJSON *pMsgCtx, int httpCode) { return NULL; } - pStrProto = cJSON_Print(pRoot); + pStrProto = cJSON_PrintUnformatted(pRoot); LOG_MOD(debug, ZLOG_MOD_PROTO, "Create: \n%s\n", pStrProto); cJSON_Delete(pRoot);