Fix use-after-free bug in Tooling.
authorAlexander Kornienko <alexfh@google.com>
Tue, 8 Jan 2019 16:55:13 +0000 (16:55 +0000)
committerAlexander Kornienko <alexfh@google.com>
Tue, 8 Jan 2019 16:55:13 +0000 (16:55 +0000)
commit973fcc25fb19b9bcd845a8f260673319b12954a5
treeb4cbde2dea1c40c4a37ee112c503a24d406e76f9
parent0d99031de0306b2ab1a21e2cd8b599acf796b6b4
Fix use-after-free bug in Tooling.

Summary:
`buildASTFromCodeWithArgs()` was creating a memory buffer referencing a
stack-allocated string.  This diff changes the implementation to copy the code
string into the memory buffer so that said buffer owns the memory.

Patch by Yitzhak Mandelbaum.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits, EricWF

Differential Revision: https://reviews.llvm.org/D55765

llvm-svn: 350638
clang/include/clang/Tooling/Tooling.h
clang/lib/Tooling/Tooling.cpp
clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp