Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a649027f
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a649027f
编写于
11月 26, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
11月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18465 from taosdata/fix/TD-20646
fix: memory leak and defects in covrity
上级
7102f628
877ffb96
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
38 deletion
+17
-38
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+0
-2
source/client/src/clientSml.c
source/client/src/clientSml.c
+16
-36
source/common/src/tname.c
source/common/src/tname.c
+1
-0
未找到文件。
source/client/src/clientMsgHandler.c
浏览文件 @
a649027f
...
...
@@ -48,8 +48,6 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) {
int32_t
processConnectRsp
(
void
*
param
,
SDataBuf
*
pMsg
,
int32_t
code
)
{
SRequestObj
*
pRequest
=
acquireRequest
(
*
(
int64_t
*
)
param
);
if
(
NULL
==
pRequest
)
{
setErrno
(
pRequest
,
TSDB_CODE_TSC_DISCONNECTED
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
goto
End
;
}
...
...
source/client/src/clientSml.c
浏览文件 @
a649027f
...
...
@@ -179,6 +179,8 @@ typedef struct {
SSmlMsgBuf
msgBuf
;
SHashObj
*
dumplicateKey
;
// for dumplicate key
SArray
*
colsContainer
;
// for cols parse, if dataFormat == false
cJSON
*
root
;
// for parse json
}
SSmlHandle
;
//=================================================================================================
...
...
@@ -1317,10 +1319,6 @@ static void smlDestroyTableInfo(SSmlHandle *info, SSmlTableInfo *tag) {
SArray
*
kvArray
=
(
SArray
*
)
taosArrayGetP
(
tag
->
cols
,
i
);
for
(
int
j
=
0
;
j
<
taosArrayGetSize
(
kvArray
);
++
j
)
{
SSmlKv
*
p
=
(
SSmlKv
*
)
taosArrayGetP
(
kvArray
,
j
);
if
(
info
->
protocol
==
TSDB_SML_JSON_PROTOCOL
&&
(
p
->
type
==
TSDB_DATA_TYPE_NCHAR
||
p
->
type
==
TSDB_DATA_TYPE_BINARY
))
{
taosMemoryFree
((
void
*
)
p
->
value
);
}
taosMemoryFree
(
p
);
}
taosArrayDestroy
(
kvArray
);
...
...
@@ -1338,17 +1336,8 @@ static void smlDestroyTableInfo(SSmlHandle *info, SSmlTableInfo *tag) {
}
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
tag
->
tags
);
i
++
)
{
SSmlKv
*
p
=
(
SSmlKv
*
)
taosArrayGetP
(
tag
->
tags
,
i
);
if
(
info
->
protocol
==
TSDB_SML_JSON_PROTOCOL
)
{
taosMemoryFree
((
void
*
)
p
->
key
);
if
(
p
->
type
==
TSDB_DATA_TYPE_NCHAR
||
p
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
taosMemoryFree
((
void
*
)
p
->
value
);
}
}
taosMemoryFree
(
p
);
}
if
(
info
->
protocol
==
TSDB_SML_JSON_PROTOCOL
&&
tag
->
sTableName
)
{
taosMemoryFree
((
void
*
)
tag
->
sTableName
);
}
taosArrayDestroy
(
tag
->
cols
);
taosArrayDestroy
(
tag
->
tags
);
taosMemoryFree
(
tag
);
...
...
@@ -1508,6 +1497,8 @@ static void smlDestroyInfo(SSmlHandle *info) {
taosArrayDestroy
(
info
->
colsContainer
);
}
destroyRequest
(
info
->
pRequest
);
cJSON_Delete
(
info
->
root
);
taosMemoryFreeClear
(
info
);
}
...
...
@@ -1583,16 +1574,6 @@ cleanup:
}
/************* TSDB_SML_JSON_PROTOCOL function start **************/
static
int32_t
smlJsonCreateSring
(
const
char
**
output
,
char
*
input
,
int32_t
inputLen
)
{
*
output
=
(
const
char
*
)
taosMemoryCalloc
(
1
,
inputLen
);
if
(
*
output
==
NULL
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
memcpy
((
void
*
)(
*
output
),
input
,
inputLen
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
smlParseMetricFromJSON
(
SSmlHandle
*
info
,
cJSON
*
root
,
SSmlTableInfo
*
tinfo
)
{
cJSON
*
metric
=
cJSON_GetObjectItem
(
root
,
"metric"
);
if
(
!
cJSON_IsString
(
metric
))
{
...
...
@@ -1605,7 +1586,8 @@ static int32_t smlParseMetricFromJSON(SSmlHandle *info, cJSON *root, SSmlTableIn
return
TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH
;
}
return
smlJsonCreateSring
(
&
tinfo
->
sTableName
,
metric
->
valuestring
,
tinfo
->
sTableNameLen
);
tinfo
->
sTableName
=
metric
->
valuestring
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
smlParseTSFromJSONObj
(
SSmlHandle
*
info
,
cJSON
*
root
,
int64_t
*
tsVal
)
{
...
...
@@ -1857,7 +1839,8 @@ static int32_t smlConvertJSONString(SSmlKv *pVal, char *typeStr, cJSON *value) {
return
TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN
;
}
return
smlJsonCreateSring
(
&
pVal
->
value
,
value
->
valuestring
,
pVal
->
length
);
pVal
->
value
=
value
->
valuestring
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
smlParseValueFromJSONObj
(
cJSON
*
root
,
SSmlKv
*
kv
)
{
...
...
@@ -2015,10 +1998,8 @@ static int32_t smlParseTagsFromJSON(cJSON *root, SArray *pKVs, char *childTableN
// key
kv
->
keyLen
=
keyLen
;
ret
=
smlJsonCreateSring
(
&
kv
->
key
,
tag
->
string
,
kv
->
keyLen
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
kv
->
key
=
tag
->
string
;
// value
ret
=
smlParseValueFromJSON
(
tag
,
kv
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -2278,16 +2259,16 @@ static int32_t smlParseJSON(SSmlHandle *info, char *payload) {
return
TSDB_CODE_TSC_INVALID_JSON
;
}
cJSON
*
root
=
cJSON_Parse
(
payload
);
if
(
root
==
NULL
)
{
info
->
root
=
cJSON_Parse
(
payload
);
if
(
info
->
root
==
NULL
)
{
uError
(
"SML:0x%"
PRIx64
" parse json failed:%s"
,
info
->
id
,
payload
);
return
TSDB_CODE_TSC_INVALID_JSON
;
}
// multiple data points must be sent in JSON array
if
(
cJSON_IsObject
(
root
))
{
if
(
cJSON_IsObject
(
info
->
root
))
{
payloadNum
=
1
;
}
else
if
(
cJSON_IsArray
(
root
))
{
payloadNum
=
cJSON_GetArraySize
(
root
);
}
else
if
(
cJSON_IsArray
(
info
->
root
))
{
payloadNum
=
cJSON_GetArraySize
(
info
->
root
);
}
else
{
uError
(
"SML:0x%"
PRIx64
" Invalid JSON Payload"
,
info
->
id
);
ret
=
TSDB_CODE_TSC_INVALID_JSON
;
...
...
@@ -2295,7 +2276,7 @@ static int32_t smlParseJSON(SSmlHandle *info, char *payload) {
}
for
(
int32_t
i
=
0
;
i
<
payloadNum
;
++
i
)
{
cJSON
*
dataPoint
=
(
payloadNum
==
1
&&
cJSON_IsObject
(
root
))
?
root
:
cJSON_GetArrayItem
(
root
,
i
);
cJSON
*
dataPoint
=
(
payloadNum
==
1
&&
cJSON_IsObject
(
info
->
root
))
?
info
->
root
:
cJSON_GetArrayItem
(
info
->
root
,
i
);
ret
=
smlParseTelnetLine
(
info
,
dataPoint
,
-
1
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" Invalid JSON Payload"
,
info
->
id
);
...
...
@@ -2304,7 +2285,6 @@ static int32_t smlParseJSON(SSmlHandle *info, char *payload) {
}
end:
cJSON_Delete
(
root
);
return
ret
;
}
...
...
source/common/src/tname.c
浏览文件 @
a649027f
...
...
@@ -316,6 +316,7 @@ static int compareKv(const void* p1, const void* p2) {
void
buildChildTableName
(
RandTableName
*
rName
)
{
SStringBuilder
sb
=
{
0
};
taosStringBuilderAppendStringLen
(
&
sb
,
rName
->
stbFullName
,
rName
->
stbFullNameLen
);
if
(
sb
.
buf
==
NULL
)
return
;
taosArraySort
(
rName
->
tags
,
compareKv
);
for
(
int
j
=
0
;
j
<
taosArrayGetSize
(
rName
->
tags
);
++
j
)
{
taosStringBuilderAppendChar
(
&
sb
,
','
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录