fix:[TD-31899] check return value by malloc/strdup
This commit is contained in:
parent
d0d49497b3
commit
f98db0d995
|
@ -727,18 +727,25 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId) {
|
||||||
tscError("failed to open file:%s since %s", filename, terrstr());
|
tscError("failed to open file:%s since %s", filename, terrstr());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
char* tmp = taosStrdup(filename);
|
|
||||||
if (tmp == NULL) {
|
|
||||||
tscError("failed to dup string:%s since %s", filename, terrstr());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (taosLockFile(pFile) < 0) {
|
if (taosLockFile(pFile) < 0) {
|
||||||
tscInfo("failed to lock file:%s since %s, maybe used by other process", filename, terrstr());
|
tscInfo("failed to lock file:%s since %s, maybe used by other process", filename, terrstr());
|
||||||
int32_t ret = taosCloseFile(&pFile);
|
int32_t ret = taosCloseFile(&pFile);
|
||||||
if (ret != 0){
|
if (ret != 0){
|
||||||
tscError("failed to close file:%p ret:%d", pFile, ret);
|
tscError("failed to close file:%p ret:%d", pFile, ret);
|
||||||
}
|
}
|
||||||
taosMemoryFree(tmp);
|
continue;
|
||||||
|
}
|
||||||
|
char* tmp = taosStrdup(filename);
|
||||||
|
if (tmp == NULL) {
|
||||||
|
tscError("failed to dup string:%s since %s", filename, terrstr());
|
||||||
|
if (taosUnLockFile(pFile) != 0) {
|
||||||
|
tscError("failed to unlock file:%s, terrno:%d", filename, terrno);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (taosCloseFile(&(pFile)) != 0) {
|
||||||
|
tscError("failed to close file:%s, terrno:%d", filename, terrno);
|
||||||
|
return;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
monitorSendSlowLogAtBeginning(clusterId, &tmp, pFile, 0);
|
monitorSendSlowLogAtBeginning(clusterId, &tmp, pFile, 0);
|
||||||
|
|
|
@ -495,10 +495,10 @@ int32_t tmq_list_append(tmq_list_t* list, const char* src) {
|
||||||
SArray* container = &list->container;
|
SArray* container = &list->container;
|
||||||
if (src == NULL || src[0] == 0) return TSDB_CODE_INVALID_PARA;
|
if (src == NULL || src[0] == 0) return TSDB_CODE_INVALID_PARA;
|
||||||
char* topic = taosStrdup(src);
|
char* topic = taosStrdup(src);
|
||||||
if (topic == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
if (topic == NULL) return terrno;
|
||||||
if (taosArrayPush(container, &topic) == NULL) {
|
if (taosArrayPush(container, &topic) == NULL) {
|
||||||
taosMemoryFree(topic);
|
taosMemoryFree(topic);
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return terrno;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3546,7 +3546,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
||||||
(void)taosThreadMutexInit(&pCommon->mutex, 0);
|
(void)taosThreadMutexInit(&pCommon->mutex, 0);
|
||||||
pCommon->pTopicName = taosStrdup(pTopic->topicName);
|
pCommon->pTopicName = taosStrdup(pTopic->topicName);
|
||||||
if (pCommon->pTopicName == NULL) {
|
if (pCommon->pTopicName == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = terrno;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
pCommon->consumerId = tmq->consumerId;
|
pCommon->consumerId = tmq->consumerId;
|
||||||
|
|
|
@ -1093,7 +1093,7 @@ int32_t taosSetSlowLogScope(char *pScopeStr, int32_t *pScope) {
|
||||||
taosMemoryFreeClear(tmp);
|
taosMemoryFreeClear(tmp);
|
||||||
tmp = taosStrdup(scope);
|
tmp = taosStrdup(scope);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
TAOS_RETURN(terrno);
|
||||||
}
|
}
|
||||||
(void)strtrim(tmp);
|
(void)strtrim(tmp);
|
||||||
if (0 == strcasecmp(tmp, "all")) {
|
if (0 == strcasecmp(tmp, "all")) {
|
||||||
|
|
|
@ -795,7 +795,7 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
|
||||||
}
|
}
|
||||||
char *pNewTopic = taosStrdup(tmp);
|
char *pNewTopic = taosStrdup(tmp);
|
||||||
if (pNewTopic == NULL) {
|
if (pNewTopic == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return terrno;
|
||||||
}
|
}
|
||||||
removeFromTopicList(pOldConsumer->rebNewTopics, pNewTopic, pOldConsumer->consumerId, "new");
|
removeFromTopicList(pOldConsumer->rebNewTopics, pNewTopic, pOldConsumer->consumerId, "new");
|
||||||
bool existing = existInCurrentTopicList(pOldConsumer, pNewTopic);
|
bool existing = existInCurrentTopicList(pOldConsumer, pNewTopic);
|
||||||
|
|
|
@ -71,7 +71,7 @@ int32_t tqOpen(const char* path, SVnode* pVnode) {
|
||||||
pVnode->pTq = pTq;
|
pVnode->pTq = pTq;
|
||||||
pTq->path = taosStrdup(path);
|
pTq->path = taosStrdup(path);
|
||||||
if (pTq->path == NULL) {
|
if (pTq->path == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return terrno;
|
||||||
}
|
}
|
||||||
pTq->pVnode = pVnode;
|
pTq->pVnode = pVnode;
|
||||||
|
|
||||||
|
|
|
@ -343,7 +343,7 @@ int32_t tqMetaCreateHandle(STQ* pTq, SMqRebVgReq* req, STqHandle* handle) {
|
||||||
if (req->subType == TOPIC_SUB_TYPE__COLUMN) {
|
if (req->subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||||
void *tmp = taosStrdup(req->qmsg);
|
void *tmp = taosStrdup(req->qmsg);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return terrno;
|
||||||
}
|
}
|
||||||
handle->execHandle.execCol.qmsg = tmp;
|
handle->execHandle.execCol.qmsg = tmp;
|
||||||
} else if (req->subType == TOPIC_SUB_TYPE__DB) {
|
} else if (req->subType == TOPIC_SUB_TYPE__DB) {
|
||||||
|
@ -356,7 +356,7 @@ int32_t tqMetaCreateHandle(STQ* pTq, SMqRebVgReq* req, STqHandle* handle) {
|
||||||
handle->execHandle.execTb.suid = req->suid;
|
handle->execHandle.execTb.suid = req->suid;
|
||||||
void *tmp = taosStrdup(req->qmsg);
|
void *tmp = taosStrdup(req->qmsg);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return terrno;
|
||||||
}
|
}
|
||||||
handle->execHandle.execTb.qmsg = tmp;
|
handle->execHandle.execTb.qmsg = tmp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, void* pRsp, int32_t
|
||||||
char* tbName = taosStrdup(mr.me.name);
|
char* tbName = taosStrdup(mr.me.name);
|
||||||
if (tbName == NULL) {
|
if (tbName == NULL) {
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return terrno;
|
||||||
}
|
}
|
||||||
if(taosArrayPush(((SMqDataRspCommon*)pRsp)->blockTbName, &tbName) == NULL){
|
if(taosArrayPush(((SMqDataRspCommon*)pRsp)->blockTbName, &tbName) == NULL){
|
||||||
continue;
|
continue;
|
||||||
|
@ -219,7 +219,7 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatc
|
||||||
char* tbName = taosStrdup(qExtractTbnameFromTask(task));
|
char* tbName = taosStrdup(qExtractTbnameFromTask(task));
|
||||||
if (tbName == NULL) {
|
if (tbName == NULL) {
|
||||||
tqError("vgId:%d, failed to add tbname to rsp msg, null", pTq->pVnode->config.vgId);
|
tqError("vgId:%d, failed to add tbname to rsp msg, null", pTq->pVnode->config.vgId);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return terrno;
|
||||||
}
|
}
|
||||||
if (taosArrayPush(pRsp->common.blockTbName, &tbName) == NULL){
|
if (taosArrayPush(pRsp->common.blockTbName, &tbName) == NULL){
|
||||||
tqError("vgId:%d, failed to add tbname to rsp msg", pTq->pVnode->config.vgId);
|
tqError("vgId:%d, failed to add tbname to rsp msg", pTq->pVnode->config.vgId);
|
||||||
|
|
Loading…
Reference in New Issue