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
034ff3ce
Commit
034ff3ce
authored
Dec 24, 2014
by
Roman Donchenko
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3497 from SpecLad:fs-open-fail-leak
parents
63bc4d4b
08da247a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
3 deletions
+20
-3
persistence.cpp
modules/core/src/persistence.cpp
+20
-3
No files found.
modules/core/src/persistence.cpp
View file @
034ff3ce
...
...
@@ -2683,7 +2683,6 @@ CV_IMPL CvFileStorage*
cvOpenFileStorage
(
const
char
*
filename
,
CvMemStorage
*
dststorage
,
int
flags
,
const
char
*
encoding
)
{
CvFileStorage
*
fs
=
0
;
char
*
xml_buf
=
0
;
int
default_block_size
=
1
<<
18
;
bool
append
=
(
flags
&
3
)
==
CV_STORAGE_APPEND
;
bool
mem
=
(
flags
&
CV_STORAGE_MEMORY
)
!=
0
;
...
...
@@ -2724,7 +2723,10 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co
(
dot_pos
[
3
]
==
'\0'
||
(
cv_isdigit
(
dot_pos
[
3
])
&&
dot_pos
[
4
]
==
'\0'
))
)
{
if
(
append
)
{
cvReleaseFileStorage
(
&
fs
);
CV_Error
(
CV_StsNotImplemented
,
"Appending data to compressed file is not implemented"
);
}
isGZ
=
true
;
compression
=
dot_pos
[
3
];
if
(
compression
)
...
...
@@ -2745,6 +2747,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co
if
(
!
fs
->
gzfile
)
goto
_exit_
;
#else
cvReleaseFileStorage
(
&
fs
);
CV_Error
(
CV_StsNotImplemented
,
"There is no compressed file storage support in this configuration"
);
#endif
}
...
...
@@ -2797,7 +2800,10 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co
if
(
strcmp
(
encoding
,
"UTF-16"
)
==
0
||
strcmp
(
encoding
,
"utf-16"
)
==
0
||
strcmp
(
encoding
,
"Utf-16"
)
==
0
)
{
cvReleaseFileStorage
(
&
fs
);
CV_Error
(
CV_StsBadArg
,
"UTF-16 XML encoding is not supported! Use 8-bit encoding
\n
"
);
}
CV_Assert
(
strlen
(
encoding
)
<
1000
);
char
buf
[
1100
];
...
...
@@ -2815,7 +2821,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co
int
last_occurence
=
-
1
;
xml_buf_size
=
MIN
(
xml_buf_size
,
int
(
file_size
));
fseek
(
fs
->
file
,
-
xml_buf_size
,
SEEK_END
);
xml_buf
=
(
char
*
)
cvAlloc
(
xml_buf_size
+
2
);
char
*
xml_buf
=
(
char
*
)
cvAlloc
(
xml_buf_size
+
2
);
// find the last occurence of </opencv_storage>
for
(;;)
{
...
...
@@ -2833,8 +2839,12 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co
ptr
+=
strlen
(
substr
);
}
}
cvFree
(
&
xml_buf
);
if
(
last_occurence
<
0
)
{
cvReleaseFileStorage
(
&
fs
);
CV_Error
(
CV_StsError
,
"Could not find </opencv_storage> in the end of file.
\n
"
);
}
icvCloseFile
(
fs
);
fs
->
file
=
fopen
(
fs
->
filename
,
"r+t"
);
fseek
(
fs
->
file
,
last_occurence
,
SEEK_SET
);
...
...
@@ -2908,10 +2918,18 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co
//mode = cvGetErrMode();
//cvSetErrMode( CV_ErrModeSilent );
try
{
if
(
fs
->
fmt
==
CV_STORAGE_FORMAT_XML
)
icvXMLParse
(
fs
);
else
icvYMLParse
(
fs
);
}
catch
(...)
{
cvReleaseFileStorage
(
&
fs
);
throw
;
}
//cvSetErrMode( mode );
// release resources that we do not need anymore
...
...
@@ -2936,7 +2954,6 @@ _exit_:
}
}
cvFree
(
&
xml_buf
);
return
fs
;
}
...
...
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