Skip to content

fix: guard FFI schema metadata on empty schema#10289

Open
cyphercodes wants to merge 1 commit into
apache:mainfrom
cyphercodes:fix-ffi-schema-with-metadata-null
Open

fix: guard FFI schema metadata on empty schema#10289
cyphercodes wants to merge 1 commit into
apache:mainfrom
cyphercodes:fix-ffi-schema-with-metadata-null

Conversation

@cyphercodes

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

FFI_ArrowSchema::empty() leaves private_data null. Calling the safe with_metadata builder on that value previously reached Box::from_raw(self.private_data as *mut SchemaPrivateData), which is undefined behavior for a null pointer.

What changes are included in this PR?

  • Return a CDataInterface error from FFI_ArrowSchema::with_metadata when private_data is null.
  • Add a regression test for calling with_metadata on FFI_ArrowSchema::empty().

Are these changes tested?

Yes:

  • cargo fmt -p arrow-schema -- --check
  • cargo test -p arrow-schema --features ffi test_set_metadata_on_empty_schema_errors -- --nocapture
  • cargo test -p arrow-schema --features ffi test_set_field_metadata -- --nocapture
  • cargo test -p arrow-schema --features ffi ffi::tests::test_schema -- --nocapture
  • cargo test -p arrow-schema --features ffi
  • cargo clippy -p arrow-schema --features ffi --all-targets -- -D warnings

Are there any user-facing changes?

No API shape changes. Calling with_metadata on an empty/released FFI schema now returns an error instead of invoking undefined behavior.

AI assistance

AI assistance was used to prepare this small patch; I reviewed the change and verified it with the commands listed above.

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Null pointer dereference in FFI_ArrowSchema::with_metadata when used with empty schema

1 participant