Skip to content

Conversation

@AliRana30
Copy link

@AliRana30 AliRana30 commented Jan 30, 2026

Rationale for This Change

The SimpleTable constructor in cpp/src/arrow/table.cc can crash if the first column provided is null. This happens because the constructor attempts to dereference columns[0] to determine the row count before performing any validation.
This change ensures safe initialization when columns are empty or the first column is null.


What Changes Are Included in This PR?

A null-pointer safety check has been added to both SimpleTable constructors to prevent dereferencing a null column during initialization:

if (columns.size() == 0 || !columns[0]) {
  num_rows_ = 0;
} else {
  num_rows_ = columns[0]->length();
}

Are These Changes Tested?

Yes. The change has been verified using the existing unit test suite.

Are There Any User-Facing Changes?

No. This change only improves internal safety and does not affect public APIs or user-visible behavior.

Closes

Closes #49079

The SimpleTable constructors dereference columns_[0] and columns[0]
without checking for null when num_rows < 0. This causes a segfault
if a user passes a vector containing null pointers, as the null check
in ValidateMeta() runs after construction.

Fixed by adding null checks before dereferencing the first column.
@github-actions
Copy link

⚠️ GitHub issue #49079 has been automatically assigned in GitHub to PR creator.

@github-actions github-actions bot added the awaiting review Awaiting review label Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review Awaiting review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C++] Null pointer dereference in SimpleTable constructor

2 participants