getMemBufferCopy triggers an UB when it receives a default constructed
StringRef. Make sure that we're always passing the null-terminated string
created in ParseInputs throughout the scanPreamble.
Details
Details
- Reviewers
hokein - Commits
- rGf393e1f6b3b4: [clangd] Fix UB in scanPreamble
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Looks like we have an extra cost here -- the std::string.substr will construct a new string everytime, we could save it by using llvm::StringRef(PI.Contents).substr(0, Bounds.Size).