Skip to content

Conversation

@hawkadrian
Copy link

Add bounds checking to prevent undefined behavior when accessing characters beyond the source string.

The method now returns '\0' when attempting to read past the end of input, maintaining consistency with other CharStream methods that handle boundary conditions safely.

@github-actions
Copy link

github-actions bot commented Oct 8, 2025

Thank you for your contribution to the Solidity compiler! A team member will follow up shortly.

If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother.

If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix.

@clonker
Copy link
Member

clonker commented Oct 9, 2025

Does this fix an actual issue you have encountered? Otherwise: CharStream behaves in exactly the same way a C/C++ string does. It is already null terminated by virtue of using std::string under the hood, ie, you get '\0' if you access stream.get(str.size()). Anything beyond that index is UB, same as for a regular string in c/c++ as well.

@hawkadrian hawkadrian closed this Oct 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants