-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for memory leak in function `ParserATNSimulator::execATNWithFullC…
…ontext`
- Loading branch information
1 parent
a02c2fa
commit 95fecce
Showing
4 changed files
with
24 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95fecce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear Mike,
since there are no proper copy constructors or assignment operators implemented, there could occure double frees here:
NoViableAltException::~NoViableAltException() {
if (_deleteConfigs)
delete _deadEndConfigs;
How to protect _deadEndConfigs against double frees?
Regards,
Christian
95fecce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Christian, where do you see a double free? What happens is that under certain conditions a new config is created and passed to the
NoViableAltException
c-tor. This is then freed in the d-tor. No other code path can remove that.In all other cases the config is already held in a
shared_ptr
and managed by that (which meansNoViableAltException
should not delete the reference.