fix: guard FFI schema metadata on empty schema#10289
Open
cyphercodes wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
FFI_ArrowSchema::with_metadatawhen used with empty schema #10286.Rationale for this change
FFI_ArrowSchema::empty()leavesprivate_datanull. Calling the safewith_metadatabuilder on that value previously reachedBox::from_raw(self.private_data as *mut SchemaPrivateData), which is undefined behavior for a null pointer.What changes are included in this PR?
CDataInterfaceerror fromFFI_ArrowSchema::with_metadatawhenprivate_datais null.with_metadataonFFI_ArrowSchema::empty().Are these changes tested?
Yes:
cargo fmt -p arrow-schema -- --checkcargo test -p arrow-schema --features ffi test_set_metadata_on_empty_schema_errors -- --nocapturecargo test -p arrow-schema --features ffi test_set_field_metadata -- --nocapturecargo test -p arrow-schema --features ffi ffi::tests::test_schema -- --nocapturecargo test -p arrow-schema --features fficargo clippy -p arrow-schema --features ffi --all-targets -- -D warningsAre there any user-facing changes?
No API shape changes. Calling
with_metadataon 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.