-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure parse_utf8
has length of string passed in when available
#99834
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be that this is changing behavior; current code is terminating on NULL even if the actual string length was larger. Not that i'm again it; just noting. The tests will probably see if it still works.
It should not, as length is just a hint to be able to allocate a destination buffer large enough to hold the result ( which is 1 to 1 if the file is just ASCII, or could be 4 to 1 if only 4 bytes codepoints). It is only used in the conversion algorithm as a stop condition, and if we iterated past the length, it was a bug, as the case I changed allocated length bytes just before the call. If it stopped on null, we will stop on null too, even if it's smaller than length. The loop condition is the same in current implementation and the PR. |
3a37be1
to
83d4bde
Compare
Thanks! |
As seen in #99826, parse utf_8 is faster when it doesn't have to find the size of the string first.
So if calling code has it, make sure to pass it along.