Skip to content

Fixed potential memory leak in flann#23276

Merged
asmorkalov merged 11 commits intoopencv:3.4from
vovka643:flann_corrections
Mar 14, 2023
Merged

Fixed potential memory leak in flann#23276
asmorkalov merged 11 commits intoopencv:3.4from
vovka643:flann_corrections

Conversation

@vovka643
Copy link
Copy Markdown
Contributor

@vovka643 vovka643 commented Feb 19, 2023

Issue #22426

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • [ x] The feature is well documented and sample code can be built with the project CMake

@asmorkalov
Copy link
Copy Markdown
Contributor

load_header function does not open the file and does not own the handle. The closed handle is not expected for the caller.. The file is public API (is in include) and may be used by external code. I propose to wrap the function call to try/catch and close the file on owner side.

@asmorkalov asmorkalov self-requested a review February 20, 2023 09:54
@asmorkalov
Copy link
Copy Markdown
Contributor

There is yet another function usage in flann/include/opencv2/flann/flann_base.hpp:82


Index(const Matrix<ElementType>& features, const IndexParams& params, Distance distance = Distance() )
: index_params_(params)
:index_params_(params)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No need to touch it.

@asmorkalov asmorkalov self-requested a review March 13, 2023 13:20
@asmorkalov asmorkalov changed the title removed potential memory leak in flann. issue #22426 Fixed potential memory leak in flann Mar 14, 2023
@asmorkalov asmorkalov self-assigned this Mar 14, 2023
@asmorkalov asmorkalov added this to the 3.4.20 milestone Mar 14, 2023
@asmorkalov asmorkalov merged commit b204c39 into opencv:3.4 Mar 14, 2023
@asmorkalov asmorkalov mentioned this pull request Apr 20, 2023
@asmorkalov asmorkalov mentioned this pull request May 31, 2023
thewoz pushed a commit to thewoz/opencv that referenced this pull request Jan 4, 2024
Fixed potential memory leak in flann

Issue opencv#22426

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
thewoz pushed a commit to thewoz/opencv that referenced this pull request May 29, 2024
Fixed potential memory leak in flann

Issue opencv#22426

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
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