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
518c6ae8
Commit
518c6ae8
authored
Aug 28, 2017
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9327 from sovrasov:fs_free_on_error_fix
parents
048feeb3
5e68b28a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
persistence.cpp
modules/core/src/persistence.cpp
+1
-0
test_io.cpp
modules/core/test/test_io.cpp
+22
-0
No files found.
modules/core/src/persistence.cpp
View file @
518c6ae8
...
...
@@ -4525,6 +4525,7 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
}
catch
(...)
{
fs
->
is_opened
=
true
;
cvReleaseFileStorage
(
&
fs
);
throw
;
}
...
...
modules/core/test/test_io.cpp
View file @
518c6ae8
...
...
@@ -1345,3 +1345,25 @@ TEST(Core_InputOutput, FileStorage_json_bool)
ASSERT_EQ
((
int
)
fs
[
"bool_false"
],
0
);
fs
.
release
();
}
TEST
(
Core_InputOutput
,
FileStorage_free_file_after_exception
)
{
const
std
::
string
fileName
=
"test.yml"
;
const
std
::
string
content
=
"%YAML:1.0
\n
cameraMatrix;:: !<tag:yaml.org,2002:opencv-matrix>
\n
"
;
fstream
testFile
;
testFile
.
open
(
fileName
.
c_str
(),
std
::
fstream
::
out
);
if
(
!
testFile
.
is_open
())
FAIL
();
testFile
<<
content
;
testFile
.
close
();
try
{
FileStorage
fs
(
fileName
,
FileStorage
::
READ
+
FileStorage
::
FORMAT_YAML
);
FAIL
();
}
catch
(
const
std
::
exception
&
)
{
}
ASSERT_EQ
(
std
::
remove
(
fileName
.
c_str
()),
0
);
}
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