Merge pull request #2206 from taosdata/hotfix/crash

[TD_543] fix coverity scan, cid:290455 286428 286450 287977 287995 29…
This commit is contained in:
Shengliang Guan 2020-06-09 16:56:22 +08:00 committed by GitHub
commit b1128fc194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 11 deletions

View File

@ -61,12 +61,10 @@ static const SDnodeComponent tsDnodeComponents[] = {
}; };
static int dnodeCreateDir(const char *dir) { static int dnodeCreateDir(const char *dir) {
struct stat dirstat; if (mkdir(dir, 0755) != 0 && errno != EEXIST) {
if (stat(dir, &dirstat) < 0) { return -1;
if (mkdir(dir, 0755) != 0 && errno != EEXIST) {
return -1;
}
} }
return 0; return 0;
} }

View File

@ -177,10 +177,12 @@ void dnodeDispatchToMgmtQueue(SRpcMsg *pMsg) {
memcpy(item, pMsg, sizeof(SRpcMsg)); memcpy(item, pMsg, sizeof(SRpcMsg));
taosWriteQitem(tsMgmtQueue, 1, item); taosWriteQitem(tsMgmtQueue, 1, item);
} else { } else {
SRpcMsg rsp; SRpcMsg rsp = {
rsp.handle = pMsg->handle; .handle = pMsg->handle,
rsp.pCont = NULL; .pCont = NULL,
rsp.code = TSDB_CODE_DND_OUT_OF_MEMORY; .code = TSDB_CODE_DND_OUT_OF_MEMORY
};
rpcSendResponse(&rsp); rpcSendResponse(&rsp);
rpcFreeCont(pMsg->pCont); rpcFreeCont(pMsg->pCont);
} }
@ -188,9 +190,9 @@ void dnodeDispatchToMgmtQueue(SRpcMsg *pMsg) {
static void *dnodeProcessMgmtQueue(void *param) { static void *dnodeProcessMgmtQueue(void *param) {
SRpcMsg *pMsg; SRpcMsg *pMsg;
SRpcMsg rsp; SRpcMsg rsp = {0};
int type; int type;
void *handle; void * handle;
while (1) { while (1) {
if (taosReadQitemFromQset(tsMgmtQset, &type, (void **) &pMsg, &handle) == 0) { if (taosReadQitemFromQset(tsMgmtQset, &type, (void **) &pMsg, &handle) == 0) {
@ -251,6 +253,7 @@ static int32_t dnodeOpenVnodes() {
if (status != TSDB_CODE_SUCCESS) { if (status != TSDB_CODE_SUCCESS) {
dPrint("Get dnode list failed"); dPrint("Get dnode list failed");
free(vnodeList);
return status; return status;
} }
@ -290,6 +293,7 @@ static void dnodeCloseVnodes() {
if (status != TSDB_CODE_SUCCESS) { if (status != TSDB_CODE_SUCCESS) {
dPrint("Get dnode list failed"); dPrint("Get dnode list failed");
free(vnodeList);
return; return;
} }
@ -456,6 +460,7 @@ static bool dnodeReadMnodeInfos() {
return false; return false;
} }
content[len] = 0;
cJSON* root = cJSON_Parse(content); cJSON* root = cJSON_Parse(content);
if (root == NULL) { if (root == NULL) {
dError("failed to read mnodeIpList.json, invalid json format"); dError("failed to read mnodeIpList.json, invalid json format");
@ -628,6 +633,7 @@ static bool dnodeReadDnodeCfg() {
return false; return false;
} }
content[len] = 0;
cJSON* root = cJSON_Parse(content); cJSON* root = cJSON_Parse(content);
if (root == NULL) { if (root == NULL) {
dError("failed to read dnodeCfg.json, invalid json format"); dError("failed to read dnodeCfg.json, invalid json format");