[opencv] 205/251: loadsave: check for errors when using temp file
Nobuhiro Iwamatsu
iwamatsu at moszumanska.debian.org
Sun Aug 27 23:27:43 UTC 2017
This is an automated email from the git hooks/post-receive script.
iwamatsu pushed a commit to annotated tag 3.3.0
in repository opencv.
commit 2be955a0ef3e5ddad18eba6b40c11c5dc72f44d4
Author: Jeremy Maitin-Shepard <jbms at google.com>
Date: Thu Jul 27 13:44:36 2017 -0700
loadsave: check for errors when using temp file
Previously, the return value of fwrite and fclose were not properly
checked, leading to possible silent truncation of the data if writing
failed, e.g. due to lack of disk space.
Fixes issue #9251.
---
modules/imgcodecs/src/loadsave.cpp | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/modules/imgcodecs/src/loadsave.cpp b/modules/imgcodecs/src/loadsave.cpp
index 2614019..3b23662 100644
--- a/modules/imgcodecs/src/loadsave.cpp
+++ b/modules/imgcodecs/src/loadsave.cpp
@@ -651,8 +651,15 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
if( !f )
return 0;
size_t bufSize = buf.cols*buf.rows*buf.elemSize();
- fwrite( buf.ptr(), 1, bufSize, f );
- fclose(f);
+ if( fwrite( buf.ptr(), 1, bufSize, f ) != bufSize )
+ {
+ fclose( f );
+ CV_Error( CV_StsError, "failed to write image data to temporary file" );
+ }
+ if( fclose(f) != 0 )
+ {
+ CV_Error( CV_StsError, "failed to write image data to temporary file" );
+ }
decoder->setSource(filename);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opencv.git
More information about the debian-science-commits
mailing list