Skip to content

Commit 2b80777

Browse files
committed
Don't leak input arrays.
1 parent 6a43e27 commit 2b80777

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

pdal/PyPipeline.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ Pipeline::Pipeline(std::string const& json, std::vector<Array*> arrays) :
9999
};
100100

101101
r.setIncrementer(incrementer);
102-
PyObject* parray = (PyObject*)array->getPythonArray();
103-
if (!parray)
104-
throw pdal_error("array was none!");
105-
106102
roots[0]->setInput(r);
107103
}
108104

pdal/libpdalpython.pyx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,28 +93,21 @@ def getDimensions():
9393

9494
cdef class PyPipeline:
9595
cdef Pipeline *thisptr # hold a c++ instance which we're wrapping
96-
96+
cdef vector[Array *] c_arrays;
9797

9898
def __cinit__(self, unicode json, list arrays=None):
9999
cdef char* x = NULL
100-
cdef Py_ssize_t n_arrays;
101-
if arrays:
102-
n_arrays = len(arrays)
103-
104-
cdef vector[Array*] c_arrays;
105-
cdef np.ndarray np_array;
106-
cdef Array* a
107100

108101
if arrays is not None:
109102
for array in arrays:
110-
a = new Array(array)
111-
c_arrays.push_back(a)
112-
113-
self.thisptr = new Pipeline(json.encode('UTF-8'), c_arrays)
103+
self.c_arrays.push_back(new Array(array))
104+
self.thisptr = new Pipeline(json.encode('UTF-8'), self.c_arrays)
114105
else:
115106
self.thisptr = new Pipeline(json.encode('UTF-8'))
116107

117108
def __dealloc__(self):
109+
for array in self.c_arrays:
110+
del array
118111
del self.thisptr
119112

120113
property pipeline:

0 commit comments

Comments
 (0)