diff --git a/fastmorph/fastmorphops.cpp b/fastmorph/fastmorphops.cpp index 13b219b..3817bec 100644 --- a/fastmorph/fastmorphops.cpp +++ b/fastmorph/fastmorphops.cpp @@ -134,9 +134,10 @@ py::array dilate_helper( } } - py::capsule capsule(output, [](void* ptr) { - delete[] ptr; + if (ptr) { + delete[] static_cast(ptr); + } }); uint64_t width = sizeof(LABEL);