Skip to content

Commit

Permalink
fix: fix memory leak if have except
Browse files Browse the repository at this point in the history
  • Loading branch information
DuanKuanJun committed Nov 21, 2024
1 parent b929ae9 commit 25af2a0
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/taosdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -3174,17 +3174,12 @@ char *queryCreateTableSql(void* taos, const char *dbName, char *tbName) {
#ifdef WEBSOCKET
}
#endif


if (ret != 0) {
closeQuery(res);
return NULL;
}

// create sql -> csql
int32_t clen = len + TSDB_DB_NAME_LEN + 128;
char *csql = (char *)calloc(1, clen);

// prefix check
const char* pre = "CREATE STABLE ";
int32_t npre = strlen(pre);
Expand Down Expand Up @@ -3213,7 +3208,9 @@ char *queryCreateTableSql(void* taos, const char *dbName, char *tbName) {
tb = tableName;
}

// combine csql
// create sql -> csql
int32_t clen = len + TSDB_DB_NAME_LEN + 128;
char *csql = (char *)calloc(1, clen);
int32_t nskip = npre + 1 + strlen(tbName) + 1;
int32_t pos = snprintf(csql, clen, "CREATE STABLE IF NOT EXISTS `%s`.`%s`", dbName, tb);
memcpy(csql + pos, data + nskip, len - nskip);
Expand Down

0 comments on commit 25af2a0

Please sign in to comment.