Skip to content

Commit 73ecf65

Browse files
committed
Fix memory leak; missed 'delete astn'.
1 parent 4f90812 commit 73ecf65

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/layoutWrapper.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,14 +434,23 @@ bool LayoutWrapper::TransferLayoutInformationTo(SBMLDocument* sbml)
434434
int speciesIndex = LIBSBMLNETWORK_CPP_NAMESPACE::getSpeciesReferenceIndexAssociatedWithSpecies(sbml, lw->m_speciesId, sid, lw->m_aliasNum, lw->m_speciesIndex);
435435
switch (m_layout_type) {
436436
case lt_linecolor:
437-
return LIBSBMLNETWORK_CPP_NAMESPACE::setStrokeColor(sbml, LIBSBMLNETWORK_CPP_NAMESPACE::getSpeciesReference(sbml, sid, 0, speciesIndex), formstring) == -1;
437+
{
438+
bool linecolorRet = LIBSBMLNETWORK_CPP_NAMESPACE::setStrokeColor(sbml, LIBSBMLNETWORK_CPP_NAMESPACE::getSpeciesReference(sbml, sid, 0, speciesIndex), formstring) == -1;
439+
delete astn;
440+
return linecolorRet;
441+
}
438442
case lt_linewidth:
439-
return LIBSBMLNETWORK_CPP_NAMESPACE::setStrokeWidth(sbml, LIBSBMLNETWORK_CPP_NAMESPACE::getSpeciesReference(sbml, sid, 0, speciesIndex), astn->getValue()) == -1;
443+
{
444+
bool linewidthRet = LIBSBMLNETWORK_CPP_NAMESPACE::setStrokeWidth(sbml, LIBSBMLNETWORK_CPP_NAMESPACE::getSpeciesReference(sbml, sid, 0, speciesIndex), astn->getValue()) == -1;
445+
delete astn;
446+
return linewidthRet;
447+
}
440448
case lt_position:
441449
default:
442450
stringstream err;
443451
err << "Cannot set the " << LayoutTypeToString(m_layout_type) << " for a reaction arc. The only options are the line color ('linecolor') and width ('linewidth').";
444452
g_registry.AddWarning(err.str());
453+
delete astn;
445454
return true;
446455
}
447456
}

0 commit comments

Comments
 (0)