Fix memory leak in GeneProductAssociation::getFbcAssociationFor.#482
Merged
Conversation
'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.
fbergmann
approved these changes
Jul 11, 2026
fbergmann
left a comment
Member
There was a problem hiding this comment.
while fbcand / fbcor ::addAssociation do not clone the association (they just call return mAssociations.append(fa); after some checks), in case of failure the added association should still be deleted.
Member
Author
|
'append' clones! That's why it's different from 'appendAndOwn'. /**
* Adds an item to the end of this ListOf's list of items.
*
* This method makes a clone of the @p item handed to it. This means that
* when the ListOf object is destroyed, the original items will not be
* destroyed. For a method with an alternative ownership behavior, see the
* ListOf::appendAndOwn(@if java SBase@endif) method.
*
* @param item the item to be added to the list.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @see appendAndOwn(SBase* disownedItem)
* @see appendFrom(const ListOf* list)
*/
int append (const SBase* item);Thanks for the review! Merging now. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
'addAssociation' cloned and added the object, but didn't delete it; 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.