timsaucer commented on code in PR #18672:
URL: https://github.com/apache/datafusion/pull/18672#discussion_r2553157110


##########
datafusion/ffi/src/udaf/accumulator.rs:
##########
@@ -173,9 +177,11 @@ unsafe extern "C" fn retract_batch_fn_wrapper(
 }
 
 unsafe extern "C" fn release_fn_wrapper(accumulator: &mut FFI_Accumulator) {
-    let private_data =
-        Box::from_raw(accumulator.private_data as *mut AccumulatorPrivateData);
-    drop(private_data);
+    if !accumulator.private_data.is_null() {

Review Comment:
   This is necessary. Now that we are no longer returning a 
`ForeignAccumulator` and instead may return the underlying struct we need to be 
certain that when we do the `drop` we don't try to double free.
   
   I also have run leak checking on all of the unit tests. With this ffi work I 
find it really important to both run the coverage analysis and leak checking. 
One of the follow on PRs has a description of that in the README also.



-- 
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]

Reply via email to