diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c index 430c7759ad..866d0cc272 100644 --- a/source/client/src/clientStmt.c +++ b/source/client/src/clientStmt.c @@ -184,10 +184,16 @@ int32_t stmtBackupQueryFields(STscStmt* pStmt) { int32_t size = pRes->numOfCols * sizeof(TAOS_FIELD); pRes->fields = taosMemoryMalloc(size); - pRes->userFields = taosMemoryMalloc(size); - if (NULL == pRes->fields || NULL == pRes->userFields) { + if (pRes->fields == NULL) { STMT_ERR_RET(terrno); } + + pRes->userFields = taosMemoryMalloc(size); + if (pRes->userFields == NULL) { + taosMemoryFreeClear(pRes->fields); + STMT_ERR_RET(terrno); + } + (void)memcpy(pRes->fields, pStmt->exec.pRequest->body.resInfo.fields, size); (void)memcpy(pRes->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size);