Skip to content

Commit

Permalink
[Python] Fix memory leaks in Python wrapper by adding missing Py_DECR…
Browse files Browse the repository at this point in the history
…EF. (#1754) (#1758)

Co-authored-by: KerstinKeller <KerstinKeller@users.noreply.github.com>
  • Loading branch information
eclipse-ecal-bot and KerstinKeller authored Oct 2, 2024
1 parent 287d908 commit 9e989cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lang/python/core/src/ecal_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/****************************************/
Expand Down Expand Up @@ -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);
}

/****************************************/
Expand Down
4 changes: 2 additions & 2 deletions lang/python/ecalhdf5/src/ecalhdf5_wrap.cxx
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9e989cb

Please sign in to comment.