Fix canny segment fault (Bug #3978)

Avoid stack overflow based on std::vector cause
std::vector::resize() segmentation fault.
This commit is contained in:
Yan Wang 2014-11-10 15:41:04 +08:00
parent 4f2aeeffaa
commit 184b6e314c

View File

@ -453,7 +453,7 @@ void cv::Canny( InputArray _src, OutputArray _dst,
if ((stack_top - stack_bottom) + src.cols > maxsize)
{
int sz = (int)(stack_top - stack_bottom);
maxsize = maxsize * 3/2;
maxsize = std::max(maxsize * 3/2, sz + src.cols);
stack.resize(maxsize);
stack_bottom = &stack[0];
stack_top = stack_bottom + sz;