Skip to content

Commit 8c01a4b

Browse files
committed
Fix memory leak.
'addAssociation' cloned and added the object; now we call 'appendAndOwn' directly so a) we don't leak, and b) we're more efficient. Still need to delete the object on failure.
1 parent bde8924 commit 8c01a4b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/sbml/packages/fbc/sbml/GeneProductAssociation.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ FbcAssociation* GeneProductAssociation::getFbcAssociationFor(const ASTNode* astn
282282
delete fbcand;
283283
return NULL;
284284
}
285-
if (fbcand->addAssociation(child_fbca) != LIBSBML_OPERATION_SUCCESS) {
285+
if (fbcand->getListOfAssociations()->appendAndOwn(child_fbca) != LIBSBML_OPERATION_SUCCESS) {
286+
delete child_fbca;
286287
delete fbcand;
287288
return NULL;
288289
}
@@ -296,7 +297,8 @@ FbcAssociation* GeneProductAssociation::getFbcAssociationFor(const ASTNode* astn
296297
delete fbcor;
297298
return NULL;
298299
}
299-
if (fbcor->addAssociation(child_fbca) != LIBSBML_OPERATION_SUCCESS) {
300+
if (fbcor->getListOfAssociations()->appendAndOwn(child_fbca) != LIBSBML_OPERATION_SUCCESS) {
301+
delete child_fbca;
300302
delete fbcor;
301303
return NULL;
302304
}

0 commit comments

Comments
 (0)