Skip to content

GH-50308: [C++][IPC] Add input size validation to SparseCSFIndex::Make#50480

Open
connorsimms wants to merge 1 commit into
apache:mainfrom
connorsimms:GH-50308-sparse-validation
Open

GH-50308: [C++][IPC] Add input size validation to SparseCSFIndex::Make#50480
connorsimms wants to merge 1 commit into
apache:mainfrom
connorsimms:GH-50308-sparse-validation

Conversation

@connorsimms

@connorsimms connorsimms commented Jul 12, 2026

Copy link
Copy Markdown

Resolves #50308

Rationale for this change

SparseCSFIndex::Make currently lacks validation for input vector sizes. This can lead to out-of-bounds memory access when provided with inconsistent input lengths. This PR adds the necessary checks to ensure that input is valid before object construction.

What changes are included in this PR?

  • Input validation in SparseCSFIndex::Make to verify axis_order is nonzero and indices_shapes, indptr_data, indices_data have consistent dimensions.
  • A unit test to verify Status::Invalid is returned when inputs are mismatched.

Are these changes tested?

Yes, cpp/src/arrow/sparse_tensor_test.cc now contains TEST(TestSparseCSFIndex, Make), which triggers the validation logic.

Are there any user-facing changes?

No.

This PR contains a "Critical Fix".
This fixes a bug that causes a segfault when invalid input parameters are passed to SparseCSFIndex::Make.

AI Usage:
AI was used to navigate the codebase and set up the build environment.

@connorsimms connorsimms requested a review from pitrou as a code owner July 12, 2026 00:14
@github-actions

Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C++][IPC] Consider validation of index sizes in SparseCSFIndex::Make

1 participant