diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 9cb47d367ba9d529d819afbb09b1ed2b753e4cfe..5cb12987574299ef693e8f4647a1fcb571ac88da 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -192,7 +192,12 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { pVnode->status = TAOS_VN_STATUS_INIT; pVnode->refCount = 1; pVnode->version = 0; - taosAddIntHash(tsDnodeVnodesHash, pVnode->vgId, (char *)(&pVnode)); + void *pData = taosAddIntHash(tsDnodeVnodesHash, pVnode->vgId, (char *)(&pVnode)); + if (pData == NULL) { + dError("pVnode:%p vgId:%d, failed to add to hash", pVnode, pVnode->vgId); + code = TSDB_CODE_VG_INIT_FAILED; + goto vnodeOpenError; + } code = vnodeReadCfg(pVnode); if (code != TSDB_CODE_SUCCESS) { @@ -278,6 +283,7 @@ vnodeOpenError: } if (pVnode != NULL) { taosDeleteIntHash(tsDnodeVnodesHash, pVnode->vgId); + free(pVnode); } return code; }