[opencv] 52/71: integer overflow fixed in getContinuousSize()
Nobuhiro Iwamatsu
iwamatsu at moszumanska.debian.org
Mon Oct 17 20:16:29 UTC 2016
This is an automated email from the git hooks/post-receive script.
iwamatsu pushed a commit to annotated tag 2.4.13.1
in repository opencv.
commit be7c924e7cd746c6febcbe45a515bee164c70453
Author: Rostislav Vasilikhin <rostislav.vasilikhin at intel.com>
Date: Fri Sep 2 01:50:54 2016 +0300
integer overflow fixed in getContinuousSize()
---
modules/core/src/precomp.hpp | 47 +++++++++++++++++++++++++-------------------
1 file changed, 27 insertions(+), 20 deletions(-)
diff --git a/modules/core/src/precomp.hpp b/modules/core/src/precomp.hpp
index c53224e..6359c38 100644
--- a/modules/core/src/precomp.hpp
+++ b/modules/core/src/precomp.hpp
@@ -127,39 +127,46 @@ template<typename T> struct OpMax
T operator ()(const T a, const T b) const { return std::max(a, b); }
};
-inline Size getContinuousSize( const Mat& m1, int widthScale=1 )
+inline Size getContinuousSize_(int flags, int cols, int rows, int widthScale)
{
- return m1.isContinuous() ? Size(m1.cols*m1.rows*widthScale, 1) :
- Size(m1.cols*widthScale, m1.rows);
+ int64 sz = (int64)cols * rows * widthScale;
+ return (flags & Mat::CONTINUOUS_FLAG) != 0 &&
+ (int)sz == sz ? Size((int)sz, 1) : Size(cols * widthScale, rows);
}
-inline Size getContinuousSize( const Mat& m1, const Mat& m2, int widthScale=1 )
+inline Size getContinuousSize(const Mat& m1, int widthScale = 1)
{
- return (m1.flags & m2.flags & Mat::CONTINUOUS_FLAG) != 0 ?
- Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
+ return getContinuousSize_(m1.flags,
+ m1.cols, m1.rows, widthScale);
}
-inline Size getContinuousSize( const Mat& m1, const Mat& m2,
- const Mat& m3, int widthScale=1 )
+inline Size getContinuousSize(const Mat& m1, const Mat& m2, int widthScale = 1)
{
- return (m1.flags & m2.flags & m3.flags & Mat::CONTINUOUS_FLAG) != 0 ?
- Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
+ return getContinuousSize_(m1.flags & m2.flags,
+ m1.cols, m1.rows, widthScale);
}
-inline Size getContinuousSize( const Mat& m1, const Mat& m2,
- const Mat& m3, const Mat& m4,
- int widthScale=1 )
+inline Size getContinuousSize(const Mat& m1, const Mat& m2,
+ const Mat& m3, int widthScale = 1)
{
- return (m1.flags & m2.flags & m3.flags & m4.flags & Mat::CONTINUOUS_FLAG) != 0 ?
- Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
+ return getContinuousSize_(m1.flags & m2.flags & m3.flags,
+ m1.cols, m1.rows, widthScale);
}
-inline Size getContinuousSize( const Mat& m1, const Mat& m2,
- const Mat& m3, const Mat& m4,
- const Mat& m5, int widthScale=1 )
+inline Size getContinuousSize(const Mat& m1, const Mat& m2,
+ const Mat& m3, const Mat& m4,
+ int widthScale = 1)
{
- return (m1.flags & m2.flags & m3.flags & m4.flags & m5.flags & Mat::CONTINUOUS_FLAG) != 0 ?
- Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
+ return getContinuousSize_(m1.flags & m2.flags & m3.flags & m4.flags,
+ m1.cols, m1.rows, widthScale);
+}
+
+inline Size getContinuousSize(const Mat& m1, const Mat& m2,
+ const Mat& m3, const Mat& m4,
+ const Mat& m5, int widthScale = 1)
+{
+ return getContinuousSize_(m1.flags & m2.flags & m3.flags & m4.flags & m5.flags,
+ m1.cols, m1.rows, widthScale);
}
struct NoVec
--
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