Repository navigation
Conversation
This was referenced Oct 22, 2026
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.
scc_copy_error(error, buffer, 0)currently subtracts one from zero before choosing how many bytes to copy. With overflow checks this can panic across the C ABI; in the tested release DLL it wraps and copies the error message despite the caller declaring no writable capacity.A direct DLL probe reproduced the write with a non-null pointer and capacity zero. The probe allocated a larger physical buffer so it could detect the unexpected write without actually overflowing that allocation.
This adds an early return for zero capacity. The pointer is never accessed in that case, so the safety documentation explicitly permits null/zero. Nonzero capacities keep the existing behavior: copy at most
capacity - 1bytes, add a null terminator, and return the number of bytes copied excluding that terminator.The regression covers capacities 0, 1, 2, 4, 5 and 8, checks untouched guard bytes and termination, and exercises null/zero. This is the same fix included in the temporary 0.5.31-cp25.2 build, where it was also checked through the exported DLL with actual compiler-error results.
Local Windows checks on this standalone patch: 6221 tests passed, workspace build, all-target Clippy and stable formatting. Commands:
scc-lib-testswas excluded because libclang is unavailable; stable rustfmt ignores the repository's nightly-only options. No general panic containment or fuzzing coverage is claimed. This patch is based directly on0.5.xand does not depend on #203 or the dependency refresh.