-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
Labels
Description
System information (version)
- OpenCV => 4.4
- Operating System / Platform => Linux (Kubuntu 18.04.5) 64 Bit
- Compiler => g++ 8.4.0
Detailed description
In module alphamat: Usage of uninitialized Mat object leads to undefined behavior (segfault) in cm.cpp function lle
Memory allocation without initialization:
Mat Cones(20, 1, DataType<float>::type), Cinv(20, 1, DataType<float>::type); |
First usage after declaration and allocation:
Cones += 1; |
Next usage of uninitialized Mat object:
opencv_contrib/modules/alphamat/src/cm.cpp
Line 126 in e320d6a
solve(C, Cones, Cinv); |
Probable solution
Change
Cones += 1; |
to
Cones = 1;
Remark
I've tested the fix on 23 images and it works for me.
Steps to reproduce
A look at the source code or a run of the example code in valgrind --track-origins=yes.
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues,
answers.opencv.org, Stack Overflow, etc and have not found solution - I updated to latest OpenCV version and the issue is still there
- There is reproducer code and related data files: videos, images, onnx, etc