Passing a nullptr to memcpy is UB.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 21670 Build 21670: arc lint + arc unit
Event Timeline
lib/Support/StringSaver.cpp | ||
---|---|---|
14 | Is it possible to reuse StringRef::copy(Allocator &) here? |
lib/Support/StringSaver.cpp | ||
---|---|---|
14 | Unfortunately, not, StringRef::copy will change the behavior. The StringRef returned here is null-terminated. |
Comment Actions
Why do we need to allocate memory in this case at all? I.e. why can't this just be:
if (S.empty()) return StringRef("", 0); ...
Is it possible to reuse StringRef::copy(Allocator &) here?