-
Notifications
You must be signed in to change notification settings - Fork 245
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
Fix incorrect std::string_view
usage
#1750
base: Piers
Are you sure you want to change the base?
Conversation
`std::string_view` is not null terminated, therefore `cbegin()`/`cend()` iterator pairs need to be used.
Those functions are thin wrappers around C functions that can't handle non null terminated strings.
in many places the use of string_view is intentional all logs changes are confusing due to additional length input
fwik all strings manged on ISA are null terminated, if it is missing there is to understand why |
Probably time to migrate to std::format?
This might very well be true, but someone who doesn't know the ins and outs of inputstream.adaptive has to check every time a function accepts a See e.g.:
This has been special cased in StringUtils: inputstream.adaptive/src/utils/StringUtils.cpp Lines 182 to 187 in d789f97
Do the same for UTILS::STRING::ToUint32 and it won't work. And that's the main problem. You can't look at a function and be certain that is does the correct thing even if you use it according to its contract.
|
Description
In many places it was assumed that
std::string_view::data()
would return a null terminated string that only contains the slice the view is pointing at. This is in general not true.Motivation and context
I became aware of this general issue when investigating #1748. This PR probably solved that issue but I'm not certain.
How has this been tested?
Test suite runs, YouTube works.
Types of change
Checklist: