ProjectExplorer: Fix Coverity warning in AbstractProcessStep

*** CID 1505141:  Null pointer dereferences  (FORWARD_NULL)
/qt-creator/src/plugins/projectexplorer/abstractprocessstep.cpp: 409 in ProjectExplorer::AbstractProcessStep::slotProcessFinished(int, QProcess::ExitStatus)()
403         if (!process) // Happens when the process was canceled and handed over to the Reaper.
404             process = qobject_cast<QtcProcess *>(sender()); // The process was canceled!
405         if (process) {
406             stdError(d->stderrStream->toUnicode(process->readAllStandardError()));
407             stdOutput(d->stdoutStream->toUnicode(process->readAllStandardOutput()));
408         }
>>>    CID 1505141:  Null pointer dereferences  (FORWARD_NULL)
>>>    Passing null pointer "process" to "cleanUp", which dereferences it.
409         d->cleanUp(process);
410     }
411

Amends 4a26a2c28.

Change-Id: If9a66841b05e389a87a1b843ee5ef9e66edf15dd
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2021-06-07 09:26:57 +02:00
parent 9f0179b7c1
commit a09851ff1f

View File

@@ -402,10 +402,9 @@ void AbstractProcessStep::slotProcessFinished(int, QProcess::ExitStatus)
QtcProcess *process = d->m_process.get(); QtcProcess *process = d->m_process.get();
if (!process) // Happens when the process was canceled and handed over to the Reaper. if (!process) // Happens when the process was canceled and handed over to the Reaper.
process = qobject_cast<QtcProcess *>(sender()); // The process was canceled! process = qobject_cast<QtcProcess *>(sender()); // The process was canceled!
if (process) { QTC_ASSERT(process, return);
stdError(d->stderrStream->toUnicode(process->readAllStandardError())); stdError(d->stderrStream->toUnicode(process->readAllStandardError()));
stdOutput(d->stdoutStream->toUnicode(process->readAllStandardOutput())); stdOutput(d->stdoutStream->toUnicode(process->readAllStandardOutput()));
}
d->cleanUp(process); d->cleanUp(process);
} }