Files
opencv-MIRROR/modules
uwezkhan ca53fa88bd photo: check polyfit coefficients in ccm Polyfit::read 🤖🤖🤖 (#30878)
ASan, ColorCorrectionModel::read + correctImage on a model whose polyfit linearization has deg: 3 and a 1x1 coefficient Mat:

ERROR: AddressSanitizer: heap-buffer-overflow
READ of size 8 in cv::ccm::Polyfit::fromEW(double) linearize.cpp:64
0x609000000a48 is located 0 bytes after 8-byte region
Polyfit::read takes deg and the coefficient Mat p from the file without checking them against each other, and fromEW then reads p.at<double>(d, 0) for every d <= deg. This affects all four polyfit linearizations (LogPolyfit stores a Polyfit). A CV_32F coefficient Mat of the right length overruns the buffer the same way.

The fix checks deg >= 0, a CV_64FC1 coefficient Mat and deg + 1 coefficients in Polyfit::read. This matches what the fitting constructor produces (cv::solve on an n x (deg+1) CV_64F system), so models saved by ColorCorrectionModel::write load as before. The regression test fails on the unpatched tree and passes with the fix. All Photo_ColorCorrection tests pass under ASan with opencv_extra data.
2026-12-02 15:45:13 +05:30
..
2026-12-02 14:53:31 +05:30
2026-12-01 23:18:38 +05:30