Skip to content

fix memory leak when exception is thrown#20293

Merged
alalek merged 2 commits intoopencv:masterfrom
endjkv:fix-mem-leak-when-throw
Jun 26, 2021
Merged

fix memory leak when exception is thrown#20293
alalek merged 2 commits intoopencv:masterfrom
endjkv:fix-mem-leak-when-throw

Conversation

@endjkv
Copy link
Copy Markdown
Contributor

@endjkv endjkv commented Jun 22, 2021

The call to setData may throw an exception without CV_THREAD_SANITIZER.

This fix is to avoid the memory leak on pData when exception is thrown.

Copy link
Copy Markdown
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.

If that exception is thrown (CV_Assert(tlsSlotsSize > slotIdx);), then it means that memory is corrupted and related objects are not in a consistent state.
Memory leak is not a real problem here. This error is not "recoverable".

Looks like it is some kind of report from static analyzers.

@endjkv endjkv force-pushed the fix-mem-leak-when-throw branch from 2b3961d to 59b09d6 Compare June 23, 2021 01:25
@alalek alalek merged commit 42d644e into opencv:master Jun 26, 2021
@alalek alalek mentioned this pull request Oct 15, 2021
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
* fix memory leak when exception is thrown
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.

2 participants