Skip to content

Commit 6c2ac63

Browse files
committed
std: fix issue regarding potential leak for the tolist() method
1 parent f01464e commit 6c2ac63

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

include/eigenpy/std-array.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
/// Copyright (c) 2023 CNRS INRIA
1+
///
2+
/// Copyright (c) 2023-2024 CNRS INRIA
3+
///
24

35
#ifndef __eigenpy_utils_std_array_hpp__
46
#define __eigenpy_utils_std_array_hpp__
@@ -138,7 +140,8 @@ struct StdArrayPythonVisitor {
138140
cl.def(indexing_suite)
139141
.def(visitor)
140142
.def("tolist", tolist, bp::arg("self"),
141-
"Returns the std::array as a Python list.");
143+
"Returns the std::array as a Python list.",
144+
bp::return_internal_reference<>());
142145
}
143146
}
144147
};

include/eigenpy/std-vector.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/// Copyright (c) 2016-2022 CNRS INRIA
1+
///
2+
/// Copyright (c) 2016-2024 CNRS INRIA
23
/// This file was taken from Pinocchio (header
34
/// <pinocchio/bindings/python/utils/std-vector.hpp>)
45
///
@@ -386,7 +387,8 @@ struct ExposeStdMethodToStdVector
386387
void visit(Class &cl) const {
387388
cl.def(m_co_visitor)
388389
.def("tolist", &FromPythonListConverter::tolist, bp::arg("self"),
389-
"Returns the std::vector as a Python list.")
390+
"Returns the std::vector as a Python list.",
391+
bp::return_internal_reference<>())
390392
.def("reserve", &Container::reserve,
391393
(bp::arg("self"), bp::arg("new_cap")),
392394
"Increase the capacity of the vector to a value that's greater "

0 commit comments

Comments
 (0)