From 9e989cb36ed33f717a11f5efff4a0e9783aa7a5a Mon Sep 17 00:00:00 2001 From: eclipse-ecal-bot <111572016+eclipse-ecal-bot@users.noreply.github.com> Date: Wed, 2 Oct 2024 10:12:32 +0200 Subject: [PATCH] [Python] Fix memory leaks in Python wrapper by adding missing Py_DECREF. (#1754) (#1758) Co-authored-by: KerstinKeller --- lang/python/core/src/ecal_wrap.cxx | 6 ++++-- lang/python/ecalhdf5/src/ecalhdf5_wrap.cxx | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lang/python/core/src/ecal_wrap.cxx b/lang/python/core/src/ecal_wrap.cxx index 7ab9165646..91d0214418 100644 --- a/lang/python/core/src/ecal_wrap.cxx +++ b/lang/python/core/src/ecal_wrap.cxx @@ -1522,7 +1522,8 @@ PyObject* mon_monitoring(PyObject* /*self*/, PyObject* /*args*/) } } - return(Py_BuildValue("iO", 0, retDict)); + auto* retVal = Py_BuildValue("iO", 0, retDict); Py_DECREF(retDict); + return(retVal); } /****************************************/ @@ -1566,7 +1567,8 @@ PyObject* mon_logging(PyObject* /*self*/, PyObject* /*args*/) } } - return(Py_BuildValue("iO", 0, retList)); + auto* retVal = Py_BuildValue("iO", 0, retList); Py_DECREF(retList); + return(retVal); } /****************************************/ diff --git a/lang/python/ecalhdf5/src/ecalhdf5_wrap.cxx b/lang/python/ecalhdf5/src/ecalhdf5_wrap.cxx index 6d126db3ef..17da3f73d7 100644 --- a/lang/python/ecalhdf5/src/ecalhdf5_wrap.cxx +++ b/lang/python/ecalhdf5/src/ecalhdf5_wrap.cxx @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -178,7 +178,7 @@ static PyObject* Meas_GetChannelNames(Meas *self, PyObject* /*args*/) for (const auto& channel : channel_names) { PyObject* ch = Py_BuildValue("s", channel.c_str()); - PyList_Append(channels, ch); + PyList_Append(channels, ch); Py_DECREF(ch); } return channels;