From 45eab946a74596bf9f87dea15e5c3cee4ae74944 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Wed, 11 Sep 2024 17:44:52 -0700 Subject: [PATCH] Fix behavior of and memory leak from getAllElements functions. The sublist wasn't being deleted, and its contents weren't being transferred. --- src/sbml/packages/render/sbml/ListOfGlobalRenderInformation.cpp | 2 ++ src/sbml/packages/render/sbml/ListOfLocalRenderInformation.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/sbml/packages/render/sbml/ListOfGlobalRenderInformation.cpp b/src/sbml/packages/render/sbml/ListOfGlobalRenderInformation.cpp index 5e7a877ea..3c8375f0a 100644 --- a/src/sbml/packages/render/sbml/ListOfGlobalRenderInformation.cpp +++ b/src/sbml/packages/render/sbml/ListOfGlobalRenderInformation.cpp @@ -789,6 +789,8 @@ ListOfGlobalRenderInformation::getAllElements(ElementFilter* filter) { List* ret = new List(); List* sublist = ListOf::getAllElements(filter); + ret->transferFrom(sublist); + delete sublist; ADD_FILTERED_POINTER(ret, sublist, mDefaultValues, filter); diff --git a/src/sbml/packages/render/sbml/ListOfLocalRenderInformation.cpp b/src/sbml/packages/render/sbml/ListOfLocalRenderInformation.cpp index 07e18eda2..32f73f3cc 100644 --- a/src/sbml/packages/render/sbml/ListOfLocalRenderInformation.cpp +++ b/src/sbml/packages/render/sbml/ListOfLocalRenderInformation.cpp @@ -760,6 +760,8 @@ ListOfLocalRenderInformation::getAllElements(ElementFilter* filter) { List* ret = new List(); List* sublist = ListOf::getAllElements(filter); + ret->transferFrom(sublist); + delete sublist; ADD_FILTERED_POINTER(ret, sublist, mDefaultValues, filter);