Skip to content

Commit 48b919c

Browse files
committed
Fix null pointer handling in drop_stream function to prevent potential crashes
1 parent a8d376b commit 48b919c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/dataframe.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ unsafe extern "C" fn drop_stream(capsule: *mut ffi::PyObject) {
6969
}
7070
let stream_ptr =
7171
ffi::PyCapsule_GetPointer(capsule, ARROW_STREAM_NAME.as_ptr()) as *mut FFI_ArrowArrayStream;
72-
if !stream_ptr.is_null() {
73-
drop(Box::from_raw(stream_ptr));
72+
if stream_ptr.is_null() {
73+
ffi::PyErr_Clear();
74+
return;
7475
}
76+
drop(Box::from_raw(stream_ptr));
7577
}
7678

7779
// https://github.com/apache/datafusion-python/pull/1016#discussion_r1983239116

0 commit comments

Comments
 (0)