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)
  • Loading branch information
KerstinKeller authored Oct 1, 2024
1 parent 0c47117 commit 60f7835
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 @@ -1301,7 +1301,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 @@ -1341,7 +1342,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 60f7835

Please sign in to comment.