Skip to content
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

surface_matching/PPF3DDetector::match : fix memory leak #2778

Merged
merged 1 commit into from
Dec 8, 2020

Conversation

eronconi
Copy link
Contributor

@eronconi eronconi commented Dec 7, 2020

I think the define guards are wrong, the accumulator is allocated with calloc regardless of _OPENMP, so it should be freed in any case.

Copy link
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contribution!

As a bugfix this patch should go into 3.4 branch first.
We will merge changes from 3.4 into master regularly (weekly/bi-weekly).

Please:

  • change "base" branch of this PR: master => 3.4 (use "Edit" button near PR title)
  • rebase your commits from master onto 3.4 branch. For example:
    git rebase -i --onto upstream/3.4 upstream/master
    (check list of your commits, save and quit (Esc + "wq" + Enter)
    where upstream is configured by following this GitHub guide and fetched (git fetch upstream).
  • push rebased commits into source branch of your fork (with --force option)

Note: no needs to re-open PR, apply changes "inplace".

@@ -583,9 +583,7 @@ void PPF3DDetector::match(const Mat& pc, std::vector<Pose3DPtr>& results, const
poseList.push_back(pose);
}

#if defined (_OPENMP)
free(accumulator);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uint* accumulator = (uint*)calloc(numAngles*n, sizeof(uint));

BTW, it is better to avoid manual memory management and use cv::AutoBuffer or std::vector.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree.

Unfortunately I found this bug while helping a friend, not using this opencv module myself I do not feel confident enough to refactor the code to a proper "C++ style" memory management.

@eronconi eronconi changed the base branch from master to 3.4 December 7, 2020 19:27
@opencv-pushbot opencv-pushbot merged commit 21c14f5 into opencv:3.4 Dec 8, 2020
@alalek alalek mentioned this pull request Dec 9, 2020
@alalek alalek mentioned this pull request Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants