Skip to content

Commit

Permalink
Additional non-nullptr protection
Browse files Browse the repository at this point in the history
  • Loading branch information
eddelbuettel committed Mar 28, 2024
1 parent 53b9e57 commit 2a27207
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions libtiledbsoma/src/utils/arrow_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,17 @@ void ArrowAdapter::release_schema(struct ArrowSchema* schema) {

void ArrowAdapter::release_array(struct ArrowArray* array) {
auto arrow_buffer = static_cast<ArrowBuffer*>(array->private_data);
LOG_TRACE(fmt::format(
"[ArrowAdapter] release_array {} use_count={}",
arrow_buffer->buffer_->name(),
arrow_buffer->buffer_.use_count()));

// Delete the ArrowBuffer, which was allocated with new.
// If the ArrowBuffer.buffer_ shared_ptr is the last reference to the
// underlying ColumnBuffer, the ColumnBuffer will be deleted.
delete arrow_buffer;
if (arrow_buffer != nullptr) {
LOG_TRACE(fmt::format(
"[ArrowAdapter] release_array {} use_count={}",
arrow_buffer->buffer_->name(),
arrow_buffer->buffer_.use_count()));

Check warning on line 102 in libtiledbsoma/src/utils/arrow_adapter.cc

View check run for this annotation

Codecov / codecov/patch

libtiledbsoma/src/utils/arrow_adapter.cc#L99-L102

Added lines #L99 - L102 were not covered by tests

// Delete the ArrowBuffer, which was allocated with new.
// If the ArrowBuffer.buffer_ shared_ptr is the last reference to the
// underlying ColumnBuffer, the ColumnBuffer will be deleted.
delete arrow_buffer;

Check warning on line 107 in libtiledbsoma/src/utils/arrow_adapter.cc

View check run for this annotation

Codecov / codecov/patch

libtiledbsoma/src/utils/arrow_adapter.cc#L107

Added line #L107 was not covered by tests
}

if (array->buffers != nullptr) {
free(array->buffers);
Expand Down

0 comments on commit 2a27207

Please sign in to comment.