Skip to content

Fix EvtRender buffer size calculations and null terminator handling#9

Open
yoavwizstein wants to merge 1 commit intorustysec:masterfrom
yoavwizstein:master
Open

Fix EvtRender buffer size calculations and null terminator handling#9
yoavwizstein wants to merge 1 commit intorustysec:masterfrom
yoavwizstein:master

Conversation

@yoavwizstein
Copy link
Copy Markdown

The EvtRender API reports BufferUsed in bytes, but the old code had two bugs that partially cancelled each other out:

buffer_used was used directly as the element count for a Vec, allocating a buffer 2x larger than needed.
buf.len() (element count) was passed as BufferSize, which expects bytes.

The net effect was that EvtRender received the correct byte size by accident, but the oversized buffer produced trailing null characters in every rendered event string.

This change:

Correctly converts buffer_used from bytes to u16 element count for allocation
Passes buf.len() * size_of::() as BufferSize (bytes, per the API contract)
Strips the null terminator at the u16 buffer level

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.

1 participant