Fix UB in QProcess deprecation warning fixes
The commits e1e08629 and 66e905b1 introduced undefined behavior. Fix this by assigning the result of takeFirst to a temporary. Change-Id: I9e29412cf632d4836b95d47e12d8c07ab0645fbb Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
249a2e3271
commit
2de3bfced3
@ -2522,7 +2522,8 @@ int QProcess::execute(const QString &command)
|
|||||||
QStringList args = splitCommand(command);
|
QStringList args = splitCommand(command);
|
||||||
if (args.isEmpty())
|
if (args.isEmpty())
|
||||||
return -2;
|
return -2;
|
||||||
return execute(args.takeFirst(), args);
|
QString program = args.takeFirst();
|
||||||
|
return execute(program, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -167,7 +167,11 @@ static inline bool launch(const QString &launcher, const QUrl &url)
|
|||||||
const bool ok = ::system(qPrintable(command + QLatin1String(" &")));
|
const bool ok = ::system(qPrintable(command + QLatin1String(" &")));
|
||||||
#else
|
#else
|
||||||
QStringList args = QProcess::splitCommand(command);
|
QStringList args = QProcess::splitCommand(command);
|
||||||
const bool ok = !args.isEmpty() && QProcess::startDetached(args.takeFirst(), args);
|
bool ok = false;
|
||||||
|
if (!args.isEmpty()) {
|
||||||
|
QString program = args.takeFirst();
|
||||||
|
ok = QProcess::startDetached(program, args);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!ok)
|
if (!ok)
|
||||||
qWarning("Launch failed (%s)", qPrintable(command));
|
qWarning("Launch failed (%s)", qPrintable(command));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user