gemini-code-assist[bot] commented on code in PR #260:
URL: https://github.com/apache/tvm-ffi/pull/260#discussion_r2518947740
##########
python/tvm_ffi/cython/function.pxi:
##########
@@ -180,6 +180,8 @@ cdef int TVMFFIPyArgSetterDLPackExchangeAPI_(
# Convert to TVM Tensor
if TVMFFITensorFromDLPackVersioned(temp_managed_tensor, 0, 0,
&temp_chandle) != 0:
+ # recycle the managed tensor to avoid leak
+ temp_managed_tensor.deleter(temp_managed_tensor)
Review Comment:

The `deleter` function pointer on `temp_managed_tensor` can be `NULL`.
Calling a `NULL` function pointer will cause a segmentation fault. Please add a
`NULL` check before calling the deleter to prevent a potential crash, similar
to the implementation in `python/tvm_ffi/cython/tensor.pxi`.
```
if temp_managed_tensor.deleter != NULL:
temp_managed_tensor.deleter(temp_managed_tensor)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]