Skip to content

Conversation

@elipsitz
Copy link
Contributor

@elipsitz elipsitz commented Dec 4, 2022

Previously, File::readString used a C-style string as an intermediate buffer via the String += operator. This treats a NUL byte as a terminator, making this function work incorrectly if the File contains binary data.

This commit switches the function to use String::concat, which doesn't treat NUL bytes any differently (and is a bit faster, because it doesn't need to use strlen).

Previously, File::readString used a C-style string as an intermediate
buffer via the String += operator. This treats a NUL byte as a
terminator, making this function work incorrectly if the File contains
binary data.

This commit switches the function to use String::concat, which doesn't
treat NUL bytes any differently (and is a bit faster, because it doesn't
need to use strlen).
Copy link
Owner

@earlephilhower earlephilhower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM.

@earlephilhower earlephilhower merged commit d35e938 into earlephilhower:master Dec 4, 2022
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.

2 participants