[clangd] Fix UB in scanPreamble
authorKadir Cetinkaya <kadircet@google.com>
Fri, 24 Feb 2023 08:52:40 +0000 (09:52 +0100)
committerKadir Cetinkaya <kadircet@google.com>
Fri, 24 Feb 2023 09:43:12 +0000 (10:43 +0100)
commitf393e1f6b3b42e8f355e64e2fb479c571ab939bc
treee64cdaf84f01a06741f744e0bd88e408ab7d57f3
parentc4972d37290ff5ab1228ecfc7280bc07a9280f92
[clangd] Fix UB in scanPreamble

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.

Differential Revision: https://reviews.llvm.org/D144708
clang-tools-extra/clangd/Preamble.cpp