Skip to content
Snippets Groups Projects
Commit 32fa5b86 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

fix memory leak when constructor throws

parent f5ecdef8
No related branches found
No related tags found
No related merge requests found
......@@ -111,8 +111,10 @@ void FormalRegExp::setRegExp(const FormalRegExpElement& regExp) {
void FormalRegExp::setRegExp(FormalRegExpElement&& regExp) {
delete this->regExp;
this->regExp = std::move(regExp).plunder();
if(!this->regExp->attachRegExp(this))
if(!this->regExp->attachRegExp(this)) {
delete this->regExp;
throw exception::AlibException("Input symbols not in the alphabet.");
}
}
 
bool FormalRegExp::removeSymbolFromAlphabet(const alphabet::Symbol & symbol) {
......
......@@ -111,8 +111,10 @@ void UnboundedRegExp::setRegExp(const UnboundedRegExpElement& regExp) {
void UnboundedRegExp::setRegExp(UnboundedRegExpElement&& regExp) {
delete this->regExp;
this->regExp = std::move(regExp).plunder();
if(!this->regExp->attachRegExp(this))
if(!this->regExp->attachRegExp(this)) {
delete this->regExp;
throw exception::AlibException("Input symbols not in the alphabet.");
}
}
 
bool UnboundedRegExp::removeSymbolFromAlphabet(const alphabet::Symbol & symbol) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment