Fix crash in QProcess::waitForStarted() on Unix.
Invoking waitForStarted() on a QProcess before or after an unsuccessful call to start() (e.g., with an empty command), would execute FD_SET with an invalid file descriptor and cause the process to abort. The bug can be reliably reproduced on OSX. Task-number: QTBUG-32958 Change-Id: Id25b7781168489281645e21571361ca1a71d43e3 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
8c3b31182c
commit
c8d9b17367
@ -1691,10 +1691,10 @@ QProcessEnvironment QProcess::processEnvironment() const
|
||||
bool QProcess::waitForStarted(int msecs)
|
||||
{
|
||||
Q_D(QProcess);
|
||||
if (d->processState == QProcess::Running)
|
||||
return true;
|
||||
if (d->processState == QProcess::Starting)
|
||||
return d->waitForStarted(msecs);
|
||||
|
||||
return d->waitForStarted(msecs);
|
||||
return d->processState == QProcess::Running;
|
||||
}
|
||||
|
||||
/*! \reimp
|
||||
|
@ -154,6 +154,7 @@ private slots:
|
||||
void invalidProgramString();
|
||||
void onlyOneStartedSignal();
|
||||
void finishProcessBeforeReadingDone();
|
||||
void waitForStartedWithoutStart();
|
||||
|
||||
// keep these at the end, since they use lots of processes and sometimes
|
||||
// caused obscure failures to occur in tests that followed them (esp. on the Mac)
|
||||
@ -2214,6 +2215,12 @@ void tst_QProcess::finishProcessBeforeReadingDone()
|
||||
QCOMPARE(lines.last(), QStringLiteral("10239 -this is a number"));
|
||||
}
|
||||
|
||||
void tst_QProcess::waitForStartedWithoutStart()
|
||||
{
|
||||
QProcess process;
|
||||
QVERIFY(!process.waitForStarted(5000));
|
||||
}
|
||||
|
||||
#endif //QT_NO_PROCESS
|
||||
|
||||
QTEST_MAIN(tst_QProcess)
|
||||
|
Loading…
Reference in New Issue
Block a user