Fix C binding empty byte buffers#7807
Open
fallintoplace 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.
Summary
opendal_byteswithout constructing a Rust slice from a null pointer.Why
C callers can reasonably pass
{ .data = NULL, .len = 0, .capacity = 0 }for an empty buffer. Rust still requiresslice::from_raw_partsto receive a non-null, aligned pointer even when the length is zero, so the old conversion could invoke undefined behavior.Tests
cargo clippy -- -D warningscmake -S . -B build -DTEST_ENABLE_ASAN=ON -DFEATURES=opendal/services-memory && cmake --build build -j4 && ./build/testscargo build --features="opendal/services-memory" && make -C tests clean all && OPENDAL_TEST=memory make -C tests behavior_test