diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 7a2daa2..cfd1ca3 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -422,11 +422,11 @@ // Add the program name to the argument list. argv[0] = nullptr; if (!program.contains(QLatin1Char('/'))) { + // findExecutable() returns its argument if it's an absolute path, + // otherwise it searches $PATH; returns empty if not found (we handle + // that case much later) const QString &exeFilePath = QStandardPaths::findExecutable(program); - if (!exeFilePath.isEmpty()) { - const QByteArray &tmp = QFile::encodeName(exeFilePath); - argv[0] = ::strdup(tmp.constData()); - } + argv[0] = ::strdup(QFile::encodeName(exeFilePath).constData()); } if (!argv[0]) argv[0] = ::strdup(encodedProgramName.constData()); @@ -978,11 +978,10 @@ QByteArray tmp; if (!program.contains(QLatin1Char('/'))) { const QString &exeFilePath = QStandardPaths::findExecutable(program); - if (!exeFilePath.isEmpty()) - tmp = QFile::encodeName(exeFilePath); - } - if (tmp.isEmpty()) + tmp = QFile::encodeName(exeFilePath); + } else { tmp = QFile::encodeName(program); + } argv[0] = tmp.data(); if (envp)