diff options
author | Aleksandr Platonov <platonov.aleksandr@huawei.com> | 2021-12-19 22:23:45 +0300 |
---|---|---|
committer | Aleksandr Platonov <platonov.aleksandr@huawei.com> | 2021-12-19 22:28:26 +0300 |
commit | 555eacf75f21cd1dfc6363d73ad187b730349543 (patch) | |
tree | 4134f19a2a2560aa9d0bba057ff3b0b24d3c1ca1 /lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp | |
parent | 1965cc469539979d66c6a7f9d1c73000a795f8f0 (diff) | |
download | llvm-555eacf75f21cd1dfc6363d73ad187b730349543.zip llvm-555eacf75f21cd1dfc6363d73ad187b730349543.tar.gz llvm-555eacf75f21cd1dfc6363d73ad187b730349543.tar.bz2 |
[clangd] Fix undefined behavior when generating error message at rename with an invalid name
`Message()` lambda uses `Reason.Details` as an input parameter for `llvm::formatv()`, but `Reason` in `Message()` is a local object.
Return value of `llvm::formatv()` contains references to its input arguments, thus `Message()` returns an object which contains a reference to `Details` field of the local object `Reason`.
This patch fixes this behavior by passing `Reason` as a reference to `Message()` to ensure that return value of `Message()` contains references to alive object and also prevents copying of `InvalidName` structure at passing it to `makeError()`.
Provided test passes on Linux+GCC with or without this patch, but fails on Windows+VisualStudio without this patch.
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D115959
Diffstat (limited to 'lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp')
0 files changed, 0 insertions, 0 deletions