-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
cv::rectangle with very large cv::Rect triggers undefined behavior sanitizer #21037
Copy link
Copy link
Open
Labels
Description
System information (version)
- OpenCV => 4.5.4
- Operating System / Platform => Linux
- Compiler => clang 12
Detailed description
cv::rectangle with a cv::Rect where x and width are std::numeric_limits::max() creates a problem because it calls Rect::br() which overflows (x+width does not fit in an int and overflows).
The external call to cv::rectangle is still valid, the internal call to cv::Rect::br() not. What should be the proper solution ?
- not allow the creation of a cv::Rect with such big values because br() (and area() ) will overflow ?
- only warn of overflows when calling br() ?
- have br() return std::numeric_limits::max() ? (probably not desirable because inaccurate, then again what is returned now is wrong)
- create a safe_br() function that caps and not overflows ?
- only fix cv::rectangle for now. Then again, other functions will probably fail.
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues,
forum.opencv.org, Stack Overflow, etc and have not found solution - I updated to latest OpenCV version and the issue is still there
Reactions are currently unavailable