Skip to content

Conversation

@febo
Copy link
Collaborator

@febo febo commented Jul 1, 2025

Problem

The Log trait has memory safety implications in its implementation, but it is not marked as unsafe. The implementation must ensure that the value returned by any of the methods correctly reflects the actual number of bytes written to the buffer. Returning a value greater than the number of bytes written to the buffer will result in undefined behavior, since it will lead to reading uninitialized memory from the buffer.

Solution

Add unsafe to Log trait to make it explicit that the trait has to be carefully implemented.

cc: @d0nutptr

@febo febo requested a review from joncinque July 1, 2025 11:25
@d0nutptr
Copy link

d0nutptr commented Jul 3, 2025

LGTM

@febo febo merged commit a0c2a98 into main Jul 10, 2025
9 checks passed
@febo febo deleted the febo/unsafe-log branch July 10, 2025 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants