Skip to content

Commit f951a6b

Browse files
committed
Fix potentially uninitialized memory
For 7d76d60
1 parent 7aa8a67 commit f951a6b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

clang/tools/driver/driver.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,9 @@ int main(int Argc, const char **Argv) {
505505
bool IsCrash = false;
506506
Driver::CommandStatus CommandStatus = Driver::CommandStatus::Ok;
507507
// Pretend the first command failed if ReproStatus is Always.
508-
const Command *FailingCommand = &*C->getJobs().begin();
508+
const Command *FailingCommand = nullptr;
509+
if (!C->getJobs().empty())
510+
FailingCommand = &*C->getJobs().begin();
509511
if (C && !C->containsError()) {
510512
SmallVector<std::pair<int, const Command *>, 4> FailingCommands;
511513
Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
@@ -542,8 +544,9 @@ int main(int Argc, const char **Argv) {
542544
// crash, but only if we're crashing due to FORCE_CLANG_DIAGNOSTICS_CRASH.
543545
if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"))
544546
llvm::dbgs() << llvm::getBugReportMsg();
545-
if (TheDriver.maybeGenerateCompilationDiagnostics(CommandStatus, ReproLevel,
546-
*C, *FailingCommand))
547+
if (FailingCommand != nullptr &&
548+
TheDriver.maybeGenerateCompilationDiagnostics(CommandStatus, ReproLevel,
549+
*C, *FailingCommand))
547550
Res = 1;
548551

549552
Diags.getClient()->finish();

0 commit comments

Comments
 (0)