-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Description
System information (version)
- OpenCV => 3.4.5
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2015
Detailed description
- Setup the Binary descriptor
- call Detect method with data from file attached
-> Crash due to memory corruption.
look at Method in file binary_descriptor.cpp
int BinaryDescriptor::EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains )
e.g. line 1584 fills in a buffer
.cpp pFirstPartEdgeX_[offsetPFirst] = x; pFirstPartEdgeY_[offsetPFirst++] = y;
The offset keep growing in the while loops, overflowing the allocated memory.
After processing finishes, there is a check (line 2221)
.cpp if( offsetPFirst > edgePixelArraySize || offsetPSecond > edgePixelArraySize ) { std::cout << "Edge drawing Error: The total number of edge pixels is larger than MaxNumOfEdgePixels, " "numofedgePixel1 = " << offsetPFirst << ", numofedgePixel2 = " << offsetPSecond << ", MaxNumOfEdgePixel=" << edgePixelArraySize << std::endl; return -1; }
This check check for a buffer overrun, but the harm has already been done.
Steps to reproduce
```.cpp
cv::Ptr<cv::line_descriptor::BinaryDescriptor> bd = cv::line_descriptor::BinaryDescriptor::createBinaryDescriptor();
bd->setNumOfOctaves(1);
bd->setReductionRatio(2);
bd->setWidthOfBand(13);
cv::Mat src = ::imread(cv::String(IMAGE_FILE));
std::vector<cv::line_descriptor::KeyLine> lines;
/* extract lines */
bd->detect(src, lines);
```