Repository navigation
Conversation
Signed-off-by: Michael Ilyin <milyin@gmail.com>
milyin
marked this pull request as draft
September 29, 2026 13:31
Signed-off-by: Michael Ilyin <milyin@gmail.com>
Signed-off-by: Michael Ilyin <milyin@gmail.com>
milyin
marked this pull request as ready for review
September 29, 2026 14:00
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.
Several getters and conversions release temporary C strings or string arrays only after building a C++ result. An allocation failure skips that release;
Idstream insertion has the same problem if the stream throws.Add internal scope guards and use them at all twelve existing temporary string/string-array conversion sites:
detail::String, based onOwned<z_owned_string_t>, protectsId::to_string, Id stream insertion,Config::get/to_string,Encoding::as_string, four Link string getters, and string deserialization.detail::StringArrayprotectsLink::get_interfacesand the zenoh-c path ofHello::get_locators. Itsas_vector()makes independent string copies. Array initialization usesz_string_array_new, which creates an allocation-free empty state on both backends and avoids zenoh-pico's missing C++ string-arrayz_internal_nulloverload.Public signatures and ownership contracts are unchanged. Hello's returned views still borrow its strings. Empty/null temporary strings convert to empty C++ strings, and length-based conversions preserve embedded null bytes.
Tests cover normal and empty conversions, embedded nulls, copies outliving C storage, injected C++ allocation failures, and throwing stream output. A custom C string deleter verifies cleanup during unwinding directly. Fault injection is confined to separate test executables; it does not affect C-side allocation.
Validation on macOS arm64:
leaks --atExitreported zero leaks for both guards' regression executables on both backends, including the allocation-failure and stream-exception paths.