fix mem leak

This commit is contained in:
yihaoDeng 2024-11-25 16:04:47 +08:00
parent 4d857b0149
commit ac012b83ec
1 changed files with 46 additions and 41 deletions

View File

@ -762,6 +762,11 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colValueNull", isNullCJson)); RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colValueNull", isNullCJson));
break; break;
} }
case TSDB_ALTER_TABLE_UPDATE_MULTI_TAG_VAL: {
break;
}
case TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS: { case TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS: {
cJSON* colName = cJSON_CreateString(vAlterTbReq.colName); cJSON* colName = cJSON_CreateString(vAlterTbReq.colName);
RAW_NULL_CHECK(colName); RAW_NULL_CHECK(colName);
@ -1855,19 +1860,19 @@ end:
typedef int32_t _raw_decode_func_(SDecoder* pDecoder, SMqDataRsp* pRsp); typedef int32_t _raw_decode_func_(SDecoder* pDecoder, SMqDataRsp* pRsp);
static int32_t decodeRawData(SDecoder* decoder, void* data, int32_t dataLen, _raw_decode_func_ func, static int32_t decodeRawData(SDecoder* decoder, void* data, int32_t dataLen, _raw_decode_func_ func,
SMqRspObj* rspObj) { SMqRspObj* rspObj) {
int8_t dataVersion = *(int8_t*)data; int8_t dataVersion = *(int8_t*)data;
if (dataVersion >= MQ_DATA_RSP_VERSION) { if (dataVersion >= MQ_DATA_RSP_VERSION) {
data = POINTER_SHIFT(data, sizeof(int8_t) + sizeof(int32_t)); data = POINTER_SHIFT(data, sizeof(int8_t) + sizeof(int32_t));
dataLen -= sizeof(int8_t) + sizeof(int32_t); dataLen -= sizeof(int8_t) + sizeof(int32_t);
} }
rspObj->resIter = -1; rspObj->resIter = -1;
tDecoderInit(decoder, data, dataLen); tDecoderInit(decoder, data, dataLen);
int32_t code = func(decoder, &rspObj->dataRsp); int32_t code = func(decoder, &rspObj->dataRsp);
if (code != 0) { if (code != 0) {
SET_ERROR_MSG("decode mq taosx data rsp failed"); SET_ERROR_MSG("decode mq taosx data rsp failed");
} }
return code; return code;
} }
static int32_t processCacheMeta(SHashObj* pVgHash, SHashObj* pNameHash, SHashObj* pMetaHash, static int32_t processCacheMeta(SHashObj* pVgHash, SHashObj* pNameHash, SHashObj* pMetaHash,
@ -2195,44 +2200,44 @@ static int32_t getOffSetLen(const SMqDataRsp* pRsp) {
typedef int32_t __encode_func__(SEncoder* pEncoder, const SMqDataRsp* pRsp); typedef int32_t __encode_func__(SEncoder* pEncoder, const SMqDataRsp* pRsp);
static int32_t encodeMqDataRsp(__encode_func__* encodeFunc, SMqDataRsp* rspObj, tmq_raw_data* raw) { static int32_t encodeMqDataRsp(__encode_func__* encodeFunc, SMqDataRsp* rspObj, tmq_raw_data* raw) {
int32_t len = 0; int32_t len = 0;
int32_t code = 0; int32_t code = 0;
SEncoder encoder = {0}; SEncoder encoder = {0};
void* buf = NULL; void* buf = NULL;
tEncodeSize(encodeFunc, rspObj, len, code); tEncodeSize(encodeFunc, rspObj, len, code);
if (code < 0) { if (code < 0) {
code = TSDB_CODE_INVALID_MSG; code = TSDB_CODE_INVALID_MSG;
goto FAILED; goto FAILED;
} }
len += sizeof(int8_t) + sizeof(int32_t); len += sizeof(int8_t) + sizeof(int32_t);
buf = taosMemoryCalloc(1, len); buf = taosMemoryCalloc(1, len);
if (buf == NULL) { if (buf == NULL) {
code = terrno; code = terrno;
goto FAILED; goto FAILED;
} }
tEncoderInit(&encoder, buf, len); tEncoderInit(&encoder, buf, len);
if (tEncodeI8(&encoder, MQ_DATA_RSP_VERSION) < 0) { if (tEncodeI8(&encoder, MQ_DATA_RSP_VERSION) < 0) {
code = TSDB_CODE_INVALID_MSG; code = TSDB_CODE_INVALID_MSG;
goto FAILED; goto FAILED;
} }
int32_t offsetLen = getOffSetLen(rspObj); int32_t offsetLen = getOffSetLen(rspObj);
if (offsetLen <= 0) { if (offsetLen <= 0) {
code = TSDB_CODE_INVALID_MSG; code = TSDB_CODE_INVALID_MSG;
goto FAILED; goto FAILED;
} }
if (tEncodeI32(&encoder, offsetLen) < 0) { if (tEncodeI32(&encoder, offsetLen) < 0) {
code = TSDB_CODE_INVALID_MSG; code = TSDB_CODE_INVALID_MSG;
goto FAILED; goto FAILED;
} }
if (encodeFunc(&encoder, rspObj) < 0) { if (encodeFunc(&encoder, rspObj) < 0) {
code = TSDB_CODE_INVALID_MSG; code = TSDB_CODE_INVALID_MSG;
goto FAILED; goto FAILED;
} }
tEncoderClear(&encoder); tEncoderClear(&encoder);
raw->raw = buf; raw->raw = buf;
raw->raw_len = len; raw->raw_len = len;
return code; return code;
FAILED: FAILED:
tEncoderClear(&encoder); tEncoderClear(&encoder);
taosMemoryFree(buf); taosMemoryFree(buf);