Skip to content

Usage of uninitialized memory in module alphamat leads to unexpected behavior. #2662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
Sintun opened this issue Sep 8, 2020 · 1 comment · Fixed by #2860
Closed
4 tasks done

Usage of uninitialized memory in module alphamat leads to unexpected behavior. #2662

Sintun opened this issue Sep 8, 2020 · 1 comment · Fixed by #2860

Comments

@Sintun
Copy link

Sintun commented Sep 8, 2020

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:

Next usage of uninitialized Mat object:

solve(C, Cones, Cinv);

Probable solution

Change


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
@alalek
Copy link
Member

alalek commented Nov 2, 2020

/cc @sunitanyk

@alalek alalek mentioned this issue Feb 7, 2021
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants