fix mem leak

This commit is contained in:
yihaoDeng 2024-09-10 19:14:27 +08:00
parent 54cf5c89e3
commit d403a6129a
1 changed files with 7 additions and 4 deletions

View File

@ -155,10 +155,13 @@ void* rpcReallocCont(void* ptr, int64_t contLen) {
char* st = (char*)ptr - TRANS_MSG_OVERHEAD; char* st = (char*)ptr - TRANS_MSG_OVERHEAD;
int64_t sz = contLen + TRANS_MSG_OVERHEAD; int64_t sz = contLen + TRANS_MSG_OVERHEAD;
st = taosMemoryRealloc(st, sz); char* nst = taosMemoryRealloc(st, sz);
if (st == NULL) { if (nst == NULL) {
taosMemoryFree(st);
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} else {
st = nst;
} }
return st + TRANS_MSG_OVERHEAD; return st + TRANS_MSG_OVERHEAD;