const char* is convertible to StringRef through std::string
Open
- Dominant language
- C++
- Stars
- 16.7k
- Forks
- 1.6k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 126
Description
https://github.com/apple/foundationdb/blob/4b66645d80e813c056779ab73d7b2d7bb7534472/flow/include/flow/Arena.h#L660 intends to block conversion from `const char*` to `StringRef` through `std::string`, but the following still compiles, and has a heap-use-after-free.
```
TEST_CASE("/flow/Arena/StringRefThroughStdString") {
StringRef s("Hello world!");
ASSERT(s == "Hello world!"_sr);
return Void();
}
```
We could delete `StringRef(const char*)` and actually block conversion, but there are many barely-correct usages we'd have to change.
Contributor guide
Assessment
This issue has not been assessed yet.