Skip to content

Fix possible memory leak in constructors#3062

Merged
wanghan-iapcm merged 7 commits intodeepmodeling:develfrom
njzjz:memory-leak-DeepPot
Dec 15, 2023
Merged

Fix possible memory leak in constructors#3062
wanghan-iapcm merged 7 commits intodeepmodeling:develfrom
njzjz:memory-leak-DeepPot

Conversation

@njzjz
Copy link
Member

@njzjz njzjz commented Dec 14, 2023

When a constructor throws an exception, it will not call the destructor as the constructor is not finished. The memory leak happens here and is detected by LeakSanitizer (thanks, @Cloudac7, for reminding me to use it). We must catch the exception, delete the memory, and re-throw the exception.

@njzjz njzjz requested a review from wanghan-iapcm December 14, 2023 21:53
@github-actions github-actions bot added the C++ label Dec 14, 2023
@codecov
Copy link

codecov bot commented Dec 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0547940) 75.73% compared to head (0977564) 75.79%.
Report is 12 commits behind head on devel.

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3062      +/-   ##
==========================================
+ Coverage   75.73%   75.79%   +0.05%     
==========================================
  Files         245      245              
  Lines       24685    24900     +215     
  Branches     1591     1597       +6     
==========================================
+ Hits        18696    18872     +176     
- Misses       5054     5090      +36     
- Partials      935      938       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants