提交 087f88a6 编写于 作者: wmmhello's avatar wmmhello

fix:malloc too large

上级 50d2a1c1
...@@ -1067,6 +1067,7 @@ void smlDestroyInfo(SSmlHandle *info) { ...@@ -1067,6 +1067,7 @@ void smlDestroyInfo(SSmlHandle *info) {
taosMemoryFree(info->lines); taosMemoryFree(info->lines);
} }
cJSON_Delete(info->root);
taosMemoryFreeClear(info); taosMemoryFreeClear(info);
} }
......
...@@ -335,6 +335,9 @@ int smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset){ ...@@ -335,6 +335,9 @@ int smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset){
(*start)++; (*start)++;
} }
} }
if(*(*start) == '\0'){
break;
}
if(*(*start) == '}'){ if(*(*start) == '}'){
(*start)++; (*start)++;
break; break;
...@@ -923,9 +926,6 @@ static int32_t smlParseJSONStringExt(SSmlHandle *info, cJSON *root, SSmlLineInfo ...@@ -923,9 +926,6 @@ static int32_t smlParseJSONStringExt(SSmlHandle *info, cJSON *root, SSmlLineInfo
cJSON *tsJson = NULL; cJSON *tsJson = NULL;
cJSON *valueJson = NULL; cJSON *valueJson = NULL;
cJSON *tagsJson = NULL; cJSON *tagsJson = NULL;
char* rootStr = cJSON_PrintUnformatted(root);
uError("rootStr:%s", rootStr);
taosMemoryFree(rootStr);
int32_t size = cJSON_GetArraySize(root); int32_t size = cJSON_GetArraySize(root);
// outmost json fields has to be exactly 4 // outmost json fields has to be exactly 4
...@@ -956,6 +956,7 @@ static int32_t smlParseJSONStringExt(SSmlHandle *info, cJSON *root, SSmlLineInfo ...@@ -956,6 +956,7 @@ static int32_t smlParseJSONStringExt(SSmlHandle *info, cJSON *root, SSmlLineInfo
} }
// Parse tags // Parse tags
bool needFree = info->dataFormat;
elements->tags = cJSON_PrintUnformatted(tagsJson); elements->tags = cJSON_PrintUnformatted(tagsJson);
elements->tagsLen = strlen(elements->tags); elements->tagsLen = strlen(elements->tags);
if(is_same_child_table_telnet(elements, &info->preLine) != 0) { if(is_same_child_table_telnet(elements, &info->preLine) != 0) {
...@@ -968,7 +969,7 @@ static int32_t smlParseJSONStringExt(SSmlHandle *info, cJSON *root, SSmlLineInfo ...@@ -968,7 +969,7 @@ static int32_t smlParseJSONStringExt(SSmlHandle *info, cJSON *root, SSmlLineInfo
} }
} }
if(info->dataFormat){ if(needFree){
taosMemoryFree(elements->tags); taosMemoryFree(elements->tags);
elements->tags = NULL; elements->tags = NULL;
} }
......
...@@ -211,8 +211,7 @@ int smlProcess_json3_Test() { ...@@ -211,8 +211,7 @@ int smlProcess_json3_Test() {
taos_free_result(pRes); taos_free_result(pRes);
const char *sql[] = { const char *sql[] = {
// "[{\"metric\":\"sys.cpu.nice3\",\"timestamp\":0,\"value\":\"18\",\"tags\":{\"host\":\"web01\",\"id\":\"t1\",\"dc\":\"lga\"}}]" "[{\"metric\":\"sys.cpu.nice3\",\"timestamp\":0,\"value\":\"18\",\"tags\":{\"host\":\"web01\",\"id\":\"t1\",\"dc\":\"lga\"}}]"
"{\"metric\": \"dcxnmr\", \"timestamp\": {\"value\": 1626006833639000000, \"type\": \"ns\"}, \"value\": {\"value\": false, \"type\": \"bool\"}, \"tags\": {\"t0\": {\"value\": false, \"type\": \"bool\"}, \"t1\": {\"value\": 127, \"type\": \"tinyint\"}, \"t2\": {\"value\": 32767, \"type\": \"smallint\"}, \"t3\": {\"value\": 2147483647, \"type\": \"int\"}, \"t4\": {\"value\": 9223372036854775807, \"type\": \"bigint\"}, \"t5\": {\"value\": 11.12345027923584, \"type\": \"float\"}, \"t6\": {\"value\": 22.123456789, \"type\": \"double\"}, \"t7\": {\"value\": \"binaryTagValue\", \"type\": \"binary\"}, \"t8\": {\"value\": \"abc{aaa\", \"type\": \"nchar\"}}}"
}; };
char *sql1[1] = {0}; char *sql1[1] = {0};
for(int i = 0; i < 1; i++){ for(int i = 0; i < 1; i++){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册