mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Fix InitLLVM argv (#4405)
`args_.push_back(nullptr);` can resize `args_`, invalidating `argv`. The order needs to be switched.
This commit is contained in:
@@ -17,13 +17,13 @@ InitLLVM::InitLLVM(int& argc, char**& argv)
|
||||
// make a copy of the argv that LLVM produces in order to support
|
||||
// mutation.
|
||||
args_(argv, argv + argc) {
|
||||
// Return our mutable copy of argv for the program to use.
|
||||
argc = args_.size();
|
||||
argv = args_.data();
|
||||
|
||||
// `argv[argc]` is expected to be a null pointer.
|
||||
// `argv[argc]` is expected to be a null pointer (may reallocate `args_`).
|
||||
args_.push_back(nullptr);
|
||||
|
||||
// Return our mutable copy of argv for the program to use.
|
||||
argc = args_.size() - 1;
|
||||
argv = args_.data();
|
||||
|
||||
llvm::setBugReportMsg(
|
||||
"Please report issues to "
|
||||
"https://github.com/carbon-language/carbon-lang/issues and include the "
|
||||
|
||||
Reference in New Issue
Block a user