Skip to content

Fix memory leak in GeneProductAssociation::getFbcAssociationFor.#482

Merged
luciansmith merged 1 commit into
developmentfrom
fix-getFbcAssociationFor-leak
Jul 11, 2026
Merged

Fix memory leak in GeneProductAssociation::getFbcAssociationFor.#482
luciansmith merged 1 commit into
developmentfrom
fix-getFbcAssociationFor-leak

Conversation

@luciansmith

Copy link
Copy Markdown
Member

'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.

'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 fbergmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@luciansmith

Copy link
Copy Markdown
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.

@luciansmith luciansmith merged commit 9235dba into development Jul 11, 2026
35 checks passed
@luciansmith luciansmith deleted the fix-getFbcAssociationFor-leak branch July 11, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants