FilterEngine::init() crashes if kernel width is 1 & BORDER_CONSTANT (Bug #1089)
Description
I tried calling the filter2D() method with a 1x2 kernel and mode BORDER_CONSTANT, which led to a vector subscript out of bounds exception.
The problem is located in filter.cpp, line 187:
if( rowBorderType BORDER_CONSTANT || columnBorderType BORDER_CONSTANT ) {
constBorderValue.resize(srcElemSize*(ksize.width - 1));
scalarToRawData(_borderValue, &constBorderValuer0, ...
Accessing constBorderValuer0 fails because the vector is resized to length 0 (because ksize.width - 1 == 0).
While a horizontal border is not needed with a kernel width of 1, a constant vertical border might still be required; therefore, this should be fixed.
Related issues
duplicates Bug #1099: dilate() and erode() can't run with 1 width element | Done |
Associated revisions
Merge pull request #1089 from SpecLad:contract-violations
History
Updated by Vadim Pisarevsky almost 14 years ago
duplicate of #1099 (or vice versa). fixed in trunk
- Status changed from Open to Done
- (deleted custom field) set to fixed