File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,18 @@ namespace sparrow::pycapsule
131131 ArrowArray* array_ptr = new ArrowArray (std::move (arrow_array));
132132
133133 PyObject* schema_capsule = PyCapsule_New (schema_ptr, arrow_schema_str.data (), release_arrow_schema_pycapsule);
134+ if (!schema_capsule) {
135+ delete schema_ptr;
136+ delete array_ptr;
137+ return {nullptr , nullptr };
138+ }
134139 PyObject* array_capsule = PyCapsule_New (array_ptr, arrow_array_str.data (), release_arrow_array_pycapsule);
140+ if (!array_capsule) {
141+ delete schema_ptr;
142+ delete array_ptr;
143+ Py_DECREF (schema_capsule);
144+ return {nullptr , nullptr };
145+ }
135146
136147 return {schema_capsule, array_capsule};
137148 }
Original file line number Diff line number Diff line change @@ -405,7 +405,7 @@ namespace sparrow::pycapsule
405405 SUBCASE (" destructor_handles_already_released_schema" )
406406 {
407407 // Create a schema with null release callback
408- ArrowSchema* schema = new ArrowSchema () ;
408+ ArrowSchema* schema = new ArrowSchema{} ;
409409 schema->release = nullptr ;
410410
411411 PyObject* capsule = PyCapsule_New (schema, " arrow_schema" , release_arrow_schema_pycapsule);
@@ -422,7 +422,7 @@ namespace sparrow::pycapsule
422422 SUBCASE (" destructor_handles_already_released_array" )
423423 {
424424 // Create an array with null release callback
425- ArrowArray* array = new ArrowArray () ;
425+ ArrowArray* array = new ArrowArray{} ;
426426 array->release = nullptr ;
427427
428428 PyObject* capsule = PyCapsule_New (array, " arrow_array" , release_arrow_array_pycapsule);
You can’t perform that action at this time.
0 commit comments