Skip to content

Commit 207218e

Browse files
authored
Fix the bug of Mat_<>::opeartor []
`template<typename _Tp> inline const _Tp* Mat_<_Tp>::operator [](int y) const` does not support 3d matrix since it checks rows. This operator[] shall check size.p[0] instead.
1 parent 502aa1f commit 207218e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/core/include/opencv2/core/mat.inl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,14 +1634,14 @@ Mat_<_Tp> Mat_<_Tp>::operator()(const std::vector<Range>& ranges) const
16341634
template<typename _Tp> inline
16351635
_Tp* Mat_<_Tp>::operator [](int y)
16361636
{
1637-
CV_DbgAssert( 0 <= y && y < rows );
1637+
CV_DbgAssert( 0 <= y && y < size.p[0] );
16381638
return (_Tp*)(data + y*step.p[0]);
16391639
}
16401640

16411641
template<typename _Tp> inline
16421642
const _Tp* Mat_<_Tp>::operator [](int y) const
16431643
{
1644-
CV_DbgAssert( 0 <= y && y < rows );
1644+
CV_DbgAssert( 0 <= y && y < size.p[0] );
16451645
return (const _Tp*)(data + y*step.p[0]);
16461646
}
16471647

0 commit comments

Comments
 (0)