提交 0e3c4b19 编写于 作者: X xywang

[TS-550]<fix>: fixed a stack overflow bug

上级 902381ce
...@@ -358,9 +358,13 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) { ...@@ -358,9 +358,13 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) {
int num_fields = taos_num_fields(pSql); int num_fields = taos_num_fields(pSql);
TAOS_FIELD *fields = taos_fetch_fields(pSql); TAOS_FIELD *fields = taos_fetch_fields(pSql);
char buf[TSDB_COL_NAME_LEN + 16];
for (int i = 0; i < num_fields; i++) { for (int i = 0; i < num_fields; i++) {
memset(buf, 0, sizeof(buf)); char *buf = calloc(1, lengths[i] + 1);
if (buf == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
memset(buf, 0, lengths[i] + 1);
int32_t ret = tscGetNthFieldResult(row, fields, lengths, i, buf); int32_t ret = tscGetNthFieldResult(row, fields, lengths, i, buf);
if (i == 0) { if (i == 0) {
...@@ -373,6 +377,9 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) { ...@@ -373,6 +377,9 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) {
} else { } else {
snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s,", buf); snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s,", buf);
} }
free(buf);
if (i == num_fields - 1) { if (i == num_fields - 1) {
sprintf(result + strlen(result) - 1, "%s", ")"); sprintf(result + strlen(result) - 1, "%s", ")");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册