From 6c2a8a51e6d40a5f46dce4ff1344065b4b2a8607 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 6 Jul 2022 21:17:52 +0800 Subject: [PATCH] fix: invalid free while create stb --- source/dnode/mnode/impl/src/mndStb.c | 4 ++-- tests/script/tsim/valgrind/basic2.sim | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index c7a89945f8..e084710e25 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -270,13 +270,12 @@ static int32_t mndStbActionInsert(SSdb *pSdb, SStbObj *pStb) { static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb) { mTrace("stb:%s, perform delete action, row:%p", pStb->name, pStb); + taosArrayDestroy(pStb->pFuncs); taosMemoryFreeClear(pStb->pColumns); taosMemoryFreeClear(pStb->pTags); taosMemoryFreeClear(pStb->comment); - taosMemoryFreeClear(pStb->pFuncs); taosMemoryFreeClear(pStb->pAst1); taosMemoryFreeClear(pStb->pAst2); - taosArrayDestroy(pStb->pFuncs); return 0; } @@ -798,6 +797,7 @@ static int32_t mndCreateStb(SMnode *pMnode, SRpcMsg *pReq, SMCreateStbReq *pCrea _OVER: mndTransDrop(pTrans); + mndStbActionDelete(pMnode->pSdb, &stbObj); return code; } diff --git a/tests/script/tsim/valgrind/basic2.sim b/tests/script/tsim/valgrind/basic2.sim index ab25b7e0b7..8781acd698 100644 --- a/tests/script/tsim/valgrind/basic2.sim +++ b/tests/script/tsim/valgrind/basic2.sim @@ -20,6 +20,8 @@ endi print =============== step2: create db sql create database db vgroups 1 +sql use db +sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned) _OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT -- GitLab