Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
5691d998
O
Opencv
项目概览
Greenplum
/
Opencv
10 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5691d998
编写于
7月 25, 2019
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core(persistence): added null ptr checks
上级
b10ec8ef
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
54 addition
and
0 deletion
+54
-0
modules/core/src/persistence_json.cpp
modules/core/src/persistence_json.cpp
+12
-0
modules/core/src/persistence_xml.cpp
modules/core/src/persistence_xml.cpp
+21
-0
modules/core/src/persistence_yml.cpp
modules/core/src/persistence_yml.cpp
+21
-0
未找到文件。
modules/core/src/persistence_json.cpp
浏览文件 @
5691d998
...
...
@@ -296,6 +296,8 @@ public:
while
(
is_eof
==
false
&&
is_completed
==
false
)
{
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
switch
(
*
ptr
)
{
/* comment */
...
...
@@ -381,6 +383,7 @@ public:
if
(
is_eof
||
!
is_completed
)
{
ptr
=
fs
->
bufferStart
();
CV_Assert
(
ptr
);
*
ptr
=
'\0'
;
fs
->
setEof
();
if
(
!
is_completed
)
...
...
@@ -392,6 +395,9 @@ public:
char
*
parseKey
(
char
*
ptr
,
FileNode
&
collection
,
FileNode
&
value_placeholder
)
{
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
if
(
*
ptr
!=
'"'
)
CV_PARSE_ERROR_CPP
(
"Key must start with
\'\"\'
"
);
...
...
@@ -430,6 +436,9 @@ public:
char
*
parseValue
(
char
*
ptr
,
FileNode
&
node
)
{
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid value input"
);
ptr
=
skipSpaces
(
ptr
);
if
(
!
ptr
||
!*
ptr
)
CV_PARSE_ERROR_CPP
(
"Unexpected End-Of-File"
);
...
...
@@ -817,6 +826,9 @@ public:
bool
parse
(
char
*
ptr
)
{
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
ptr
=
skipSpaces
(
ptr
);
if
(
!
ptr
||
!*
ptr
)
return
false
;
...
...
modules/core/src/persistence_xml.cpp
浏览文件 @
5691d998
...
...
@@ -360,6 +360,9 @@ public:
char
*
skipSpaces
(
char
*
ptr
,
int
mode
)
{
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
int
level
=
0
;
for
(;;)
...
...
@@ -441,6 +444,9 @@ public:
char
*
parseValue
(
char
*
ptr
,
FileNode
&
node
)
{
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
FileNode
new_elem
;
bool
have_space
=
true
;
int
value_type
=
node
.
type
();
...
...
@@ -456,6 +462,8 @@ public:
(
c
==
'<'
&&
ptr
[
1
]
==
'!'
&&
ptr
[
2
]
==
'-'
)
)
{
ptr
=
skipSpaces
(
ptr
,
0
);
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
have_space
=
true
;
c
=
*
ptr
;
}
...
...
@@ -502,6 +510,8 @@ public:
{
ptr
=
fs
->
parseBase64
(
ptr
,
0
,
new_elem
);
ptr
=
skipSpaces
(
ptr
,
0
);
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
}
ptr
=
parseTag
(
ptr
,
key2
,
type_name
,
tag_type
);
...
...
@@ -645,6 +655,9 @@ public:
char
*
parseTag
(
char
*
ptr
,
std
::
string
&
tag_name
,
std
::
string
&
type_name
,
int
&
tag_type
)
{
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid tag input"
);
if
(
*
ptr
==
'\0'
)
CV_PARSE_ERROR_CPP
(
"Unexpected end of the stream"
);
...
...
@@ -702,6 +715,8 @@ public:
if
(
*
ptr
!=
'='
)
{
ptr
=
skipSpaces
(
ptr
,
CV_XML_INSIDE_TAG
);
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid attribute"
);
if
(
*
ptr
!=
'='
)
CV_PARSE_ERROR_CPP
(
"Attribute name should be followed by
\'
=
\'
"
);
}
...
...
@@ -740,6 +755,8 @@ public:
if
(
c
!=
'>'
)
{
ptr
=
skipSpaces
(
ptr
,
CV_XML_INSIDE_TAG
);
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
c
=
*
ptr
;
}
...
...
@@ -781,6 +798,8 @@ public:
// CV_XML_INSIDE_TAG is used to prohibit leading comments
ptr
=
skipSpaces
(
ptr
,
CV_XML_INSIDE_TAG
);
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
if
(
memcmp
(
ptr
,
"<?xml"
,
5
)
!=
0
)
// FIXIT ptr[1..] - out of bounds read without check
CV_PARSE_ERROR_CPP
(
"Valid XML should start with
\'
<?xml ...?>
\'
"
);
...
...
@@ -791,6 +810,8 @@ public:
while
(
ptr
&&
*
ptr
!=
'\0'
)
{
ptr
=
skipSpaces
(
ptr
,
0
);
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
if
(
*
ptr
!=
'\0'
)
{
...
...
modules/core/src/persistence_yml.cpp
浏览文件 @
5691d998
...
...
@@ -330,6 +330,9 @@ public:
char
*
skipSpaces
(
char
*
ptr
,
int
min_indent
,
int
max_comment_indent
)
{
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
for
(;;)
{
while
(
*
ptr
==
' '
)
...
...
@@ -374,6 +377,9 @@ public:
bool
getBase64Row
(
char
*
ptr
,
int
indent
,
char
*
&
beg
,
char
*
&
end
)
{
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
beg
=
end
=
ptr
=
skipSpaces
(
ptr
,
0
,
INT_MAX
);
if
(
!
ptr
||
!*
ptr
)
return
false
;
// end of file
...
...
@@ -394,6 +400,9 @@ public:
char
*
parseKey
(
char
*
ptr
,
FileNode
&
map_node
,
FileNode
&
value_placeholder
)
{
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
char
c
;
char
*
endptr
=
ptr
-
1
,
*
saveptr
;
...
...
@@ -422,6 +431,9 @@ public:
char
*
parseValue
(
char
*
ptr
,
FileNode
&
node
,
int
min_indent
,
bool
is_parent_flow
)
{
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
char
*
endptr
=
0
;
char
c
=
ptr
[
0
],
d
=
ptr
[
1
];
int
value_type
=
FileNode
::
NONE
;
...
...
@@ -508,6 +520,8 @@ public:
*
endptr
=
d
;
ptr
=
skipSpaces
(
endptr
,
min_indent
,
INT_MAX
);
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
c
=
*
ptr
;
...
...
@@ -634,6 +648,8 @@ public:
FileNode
elem
;
ptr
=
skipSpaces
(
ptr
,
new_min_indent
,
INT_MAX
);
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
if
(
*
ptr
==
'}'
||
*
ptr
==
']'
)
{
if
(
*
ptr
!=
d
)
...
...
@@ -647,6 +663,8 @@ public:
if
(
*
ptr
!=
','
)
CV_PARSE_ERROR_CPP
(
"Missing , between the elements"
);
ptr
=
skipSpaces
(
ptr
+
1
,
new_min_indent
,
INT_MAX
);
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
}
if
(
struct_type
==
FileNode
::
MAP
)
...
...
@@ -746,6 +764,9 @@ public:
bool
parse
(
char
*
ptr
)
{
if
(
!
ptr
)
CV_PARSE_ERROR_CPP
(
"Invalid input"
);
bool
first
=
true
;
bool
ok
=
true
;
FileNode
root_collection
(
fs
->
getFS
(),
0
,
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录