diff --git a/mlir/lib/ExecutionEngine/SparseUtils.cpp b/mlir/lib/ExecutionEngine/SparseUtils.cpp --- a/mlir/lib/ExecutionEngine/SparseUtils.cpp +++ b/mlir/lib/ExecutionEngine/SparseUtils.cpp @@ -635,16 +635,18 @@ } #define IMPL_GETNEXT(NAME, V) \ - bool _mlir_ciface_##NAME(void *ptr, StridedMemRefType *iref, \ + bool _mlir_ciface_##NAME(void *tensor, StridedMemRefType *iref, \ StridedMemRefType *vref) { \ assert(iref->strides[0] == 1); \ uint64_t *indx = iref->data + iref->offset; \ V *value = vref->data + vref->offset; \ const uint64_t isize = iref->sizes[0]; \ - auto iter = static_cast *>(ptr); \ + auto iter = static_cast *>(tensor); \ const Element *elem = iter->getNext(); \ - if (elem == nullptr) \ + if (elem == nullptr) { \ + delete iter; \ return false; \ + } \ for (uint64_t r = 0; r < isize; r++) \ indx[r] = elem->indices[r]; \ *value = elem->value; \