Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
00112bbe
Commit
00112bbe
authored
8 years ago
by
Philipp Hasper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
persistence: fixing crash with space-only values
parent
22682f93
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
persistence.cpp
modules/core/src/persistence.cpp
+1
-1
test_io.cpp
modules/core/test/test_io.cpp
+16
-0
No files found.
modules/core/src/persistence.cpp
View file @
00112bbe
...
...
@@ -1852,7 +1852,7 @@ icvYMLWriteString( CvFileStorage* fs, const char* key,
if
(
quote
||
len
==
0
||
str
[
0
]
!=
str
[
len
-
1
]
||
(
str
[
0
]
!=
'\"'
&&
str
[
0
]
!=
'\''
)
)
{
int
need_quote
=
quote
||
len
==
0
;
int
need_quote
=
quote
||
len
==
0
||
str
[
0
]
==
' '
;
data
=
buf
;
*
data
++
=
'\"'
;
for
(
i
=
0
;
i
<
len
;
i
++
)
...
...
This diff is collapsed.
Click to expand it.
modules/core/test/test_io.cpp
View file @
00112bbe
...
...
@@ -578,6 +578,22 @@ TEST(Core_InputOutput, FileStorageKey)
ASSERT_STREQ
(
f
.
releaseAndGetString
().
c_str
(),
expected
.
c_str
());
}
TEST
(
Core_InputOutput
,
FileStorageSpaces
)
{
cv
::
FileStorage
f
(
"dummy.yml"
,
cv
::
FileStorage
::
WRITE
|
cv
::
FileStorage
::
MEMORY
);
const
int
valueCount
=
5
;
std
::
string
values
[
5
]
=
{
""
,
" "
,
" "
,
" a"
,
" some string"
};
for
(
size_t
i
=
0
;
i
<
valueCount
;
i
++
)
{
EXPECT_NO_THROW
(
f
<<
cv
::
format
(
"key%d"
,
i
)
<<
values
[
i
]);
}
cv
::
FileStorage
f2
(
f
.
releaseAndGetString
(),
cv
::
FileStorage
::
READ
|
cv
::
FileStorage
::
MEMORY
);
std
::
string
valuesRead
[
valueCount
];
for
(
size_t
i
=
0
;
i
<
valueCount
;
i
++
)
{
EXPECT_NO_THROW
(
f2
[
cv
::
format
(
"key%d"
,
i
)]
>>
valuesRead
[
i
]);
ASSERT_STREQ
(
values
[
i
].
c_str
(),
valuesRead
[
i
].
c_str
());
}
}
TEST
(
Core_InputOutput
,
filestorage_yml_compatibility
)
{
// TODO:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment