Skip to content

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

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

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions modules/surface_matching/src/ppf_match_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.

#endif
}

// TODO : Make the parameters relative if not arguments.
Expand Down