From 2de3bfced35ae060acffc06e66e18279de6f5099 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 6 Mar 2020 09:44:05 +0100 Subject: 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 --- src/platformsupport/services/genericunix/qgenericunixservices.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp index 8e9923e208..b583d636c0 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp +++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp @@ -167,7 +167,11 @@ static inline bool launch(const QString &launcher, const QUrl &url) const bool ok = ::system(qPrintable(command + QLatin1String(" &"))); #else 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 if (!ok) qWarning("Launch failed (%s)", qPrintable(command)); -- cgit v1.2.3