fix/check-memalloc-result
This commit is contained in:
parent
3b3a0fbe62
commit
7d8857d257
|
@ -2281,6 +2281,10 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
int32_t bytes = pShow->pMeta->pSchemas[cols].bytes;
|
int32_t bytes = pShow->pMeta->pSchemas[cols].bytes;
|
||||||
char *buf = taosMemoryMalloc(bytes);
|
char *buf = taosMemoryMalloc(bytes);
|
||||||
|
if (buf == NULL) {
|
||||||
|
mError("db:%s, failed to malloc buffer", pDb->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
|
|
@ -184,6 +184,7 @@ static int32_t mndFuncActionDelete(SSdb *pSdb, SFuncObj *pFunc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndFuncActionUpdate(SSdb *pSdb, SFuncObj *pOld, SFuncObj *pNew) {
|
static int32_t mndFuncActionUpdate(SSdb *pSdb, SFuncObj *pOld, SFuncObj *pNew) {
|
||||||
|
int32_t code = 0;
|
||||||
mTrace("func:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew);
|
mTrace("func:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew);
|
||||||
|
|
||||||
taosWLockLatch(&pOld->lock);
|
taosWLockLatch(&pOld->lock);
|
||||||
|
@ -205,6 +206,11 @@ static int32_t mndFuncActionUpdate(SSdb *pSdb, SFuncObj *pOld, SFuncObj *pNew) {
|
||||||
if (pNew->commentSize > 0 && pNew->pComment != NULL) {
|
if (pNew->commentSize > 0 && pNew->pComment != NULL) {
|
||||||
pOld->commentSize = pNew->commentSize;
|
pOld->commentSize = pNew->commentSize;
|
||||||
pOld->pComment = taosMemoryMalloc(pOld->commentSize);
|
pOld->pComment = taosMemoryMalloc(pOld->commentSize);
|
||||||
|
if (pOld->pComment == NULL) {
|
||||||
|
code = terrno;
|
||||||
|
taosWUnLockLatch(&pOld->lock);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
(void)memcpy(pOld->pComment, pNew->pComment, pOld->commentSize);
|
(void)memcpy(pOld->pComment, pNew->pComment, pOld->commentSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +221,11 @@ static int32_t mndFuncActionUpdate(SSdb *pSdb, SFuncObj *pOld, SFuncObj *pNew) {
|
||||||
if (pNew->codeSize > 0 && pNew->pCode != NULL) {
|
if (pNew->codeSize > 0 && pNew->pCode != NULL) {
|
||||||
pOld->codeSize = pNew->codeSize;
|
pOld->codeSize = pNew->codeSize;
|
||||||
pOld->pCode = taosMemoryMalloc(pOld->codeSize);
|
pOld->pCode = taosMemoryMalloc(pOld->codeSize);
|
||||||
|
if (pOld->pCode == NULL) {
|
||||||
|
code = terrno;
|
||||||
|
taosWUnLockLatch(&pOld->lock);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
(void)memcpy(pOld->pCode, pNew->pCode, pOld->codeSize);
|
(void)memcpy(pOld->pCode, pNew->pCode, pOld->codeSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,6 +272,10 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
|
||||||
if (NULL != pCreate->pComment) {
|
if (NULL != pCreate->pComment) {
|
||||||
func.commentSize = strlen(pCreate->pComment) + 1;
|
func.commentSize = strlen(pCreate->pComment) + 1;
|
||||||
func.pComment = taosMemoryMalloc(func.commentSize);
|
func.pComment = taosMemoryMalloc(func.commentSize);
|
||||||
|
if (func.pComment == NULL) {
|
||||||
|
code = terrno;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
func.codeSize = pCreate->codeLen;
|
func.codeSize = pCreate->codeLen;
|
||||||
func.pCode = taosMemoryMalloc(func.codeSize);
|
func.pCode = taosMemoryMalloc(func.codeSize);
|
||||||
|
@ -716,6 +731,11 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
||||||
? TSDB_MAX_BINARY_LEN
|
? TSDB_MAX_BINARY_LEN
|
||||||
: pFunc->codeSize + VARSTR_HEADER_SIZE;
|
: pFunc->codeSize + VARSTR_HEADER_SIZE;
|
||||||
char *b4 = taosMemoryMalloc(varCodeLen);
|
char *b4 = taosMemoryMalloc(varCodeLen);
|
||||||
|
if (b4 == NULL) {
|
||||||
|
code = terrno;
|
||||||
|
sdbRelease(pSdb, pFunc);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
(void)memcpy(varDataVal(b4), pFunc->pCode, varCodeLen - VARSTR_HEADER_SIZE);
|
(void)memcpy(varDataVal(b4), pFunc->pCode, varCodeLen - VARSTR_HEADER_SIZE);
|
||||||
varDataSetLen(b4, varCodeLen - VARSTR_HEADER_SIZE);
|
varDataSetLen(b4, varCodeLen - VARSTR_HEADER_SIZE);
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)b4, false);
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)b4, false);
|
||||||
|
|
|
@ -343,6 +343,10 @@ static int32_t mndBuildCreateMnodeRedoAction(STrans *pTrans, SDCreateMnodeReq *p
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pCreateReq);
|
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pCreateReq);
|
||||||
void *pReq = taosMemoryMalloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
|
if (pReq == NULL) {
|
||||||
|
code = terrno;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
code = tSerializeSDCreateMnodeReq(pReq, contLen, pCreateReq);
|
code = tSerializeSDCreateMnodeReq(pReq, contLen, pCreateReq);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
|
@ -369,6 +373,10 @@ static int32_t mndBuildAlterMnodeTypeRedoAction(STrans *pTrans, SDAlterMnodeType
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pAlterMnodeTypeReq);
|
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pAlterMnodeTypeReq);
|
||||||
void *pReq = taosMemoryMalloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
|
if (pReq == NULL) {
|
||||||
|
code = terrno;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
code = tSerializeSDCreateMnodeReq(pReq, contLen, pAlterMnodeTypeReq);
|
code = tSerializeSDCreateMnodeReq(pReq, contLen, pAlterMnodeTypeReq);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
|
@ -395,6 +403,10 @@ static int32_t mndBuildAlterMnodeRedoAction(STrans *pTrans, SDCreateMnodeReq *pA
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pAlterReq);
|
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pAlterReq);
|
||||||
void *pReq = taosMemoryMalloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
|
if (pReq == NULL) {
|
||||||
|
code = terrno;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
code = tSerializeSDCreateMnodeReq(pReq, contLen, pAlterReq);
|
code = tSerializeSDCreateMnodeReq(pReq, contLen, pAlterReq);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
|
@ -420,6 +432,10 @@ static int32_t mndBuildDropMnodeRedoAction(STrans *pTrans, SDDropMnodeReq *pDrop
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t contLen = tSerializeSCreateDropMQSNodeReq(NULL, 0, pDropReq);
|
int32_t contLen = tSerializeSCreateDropMQSNodeReq(NULL, 0, pDropReq);
|
||||||
void *pReq = taosMemoryMalloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
|
if (pReq == NULL) {
|
||||||
|
code = terrno;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
code = tSerializeSCreateDropMQSNodeReq(pReq, contLen, pDropReq);
|
code = tSerializeSCreateDropMQSNodeReq(pReq, contLen, pDropReq);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
|
|
|
@ -2352,6 +2352,11 @@ static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, SStbObj *pObj, void **pCont, i
|
||||||
}
|
}
|
||||||
|
|
||||||
void *cont = taosMemoryMalloc(contLen);
|
void *cont = taosMemoryMalloc(contLen);
|
||||||
|
if (NULL == cont) {
|
||||||
|
code = terrno;
|
||||||
|
tFreeSMAlterStbRsp(&alterRsp);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
tEncoderInit(&ec, cont, contLen);
|
tEncoderInit(&ec, cont, contLen);
|
||||||
code = tEncodeSMAlterStbRsp(&ec, &alterRsp);
|
code = tEncodeSMAlterStbRsp(&ec, &alterRsp);
|
||||||
tEncoderClear(&ec);
|
tEncoderClear(&ec);
|
||||||
|
@ -2407,6 +2412,11 @@ int32_t mndBuildSMCreateStbRsp(SMnode *pMnode, char *dbFName, char *stbFName, vo
|
||||||
}
|
}
|
||||||
|
|
||||||
void *cont = taosMemoryMalloc(contLen);
|
void *cont = taosMemoryMalloc(contLen);
|
||||||
|
if (NULL == cont) {
|
||||||
|
code = terrno;
|
||||||
|
tFreeSMCreateStbRsp(&stbRsp);
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
tEncoderInit(&ec, cont, contLen);
|
tEncoderInit(&ec, cont, contLen);
|
||||||
TAOS_CHECK_GOTO(tEncodeSMCreateStbRsp(&ec, &stbRsp), NULL, _OVER);
|
TAOS_CHECK_GOTO(tEncodeSMCreateStbRsp(&ec, &stbRsp), NULL, _OVER);
|
||||||
tEncoderClear(&ec);
|
tEncoderClear(&ec);
|
||||||
|
|
Loading…
Reference in New Issue