qtmain_winrt: Avoid nullptrs in str*cmp which cause crashes

When bringing an application back to foreground, args may contain NULL.
These nullptrs should not cause application crashes.

Fixes: QTBUG-75843
Change-Id: I642e3c359216e7706bcb13508399999a51a4fc2d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Oliver Wolff 2019-05-17 09:12:45 +02:00
parent b7aea2bcd3
commit a96a33d993

View File

@ -317,23 +317,26 @@ private:
if (quote)
break;
commandLine[i] = '\0';
if (args.last()[0] != '\0')
if (!args.isEmpty() && args.last() && args.last()[0] != '\0')
args.append(commandLine.data() + i + 1);
// fall through
default:
if (args.last()[0] == '\0')
if (!args.isEmpty() && args.last() && args.last()[0] == '\0')
args.last() = commandLine.data() + i;
escape = false; // only quotes are escaped
break;
}
}
if (args.count() >= 2 && strncmp(args.at(1), "-ServerName:", 12) == 0)
if (args.count() >= 2 && args.at(1) && strncmp(args.at(1), "-ServerName:", 12) == 0)
args.remove(1);
bool develMode = false;
bool debugWait = false;
for (int i = args.count() - 1; i >= 0; --i) {
if (!args.at(i))
continue;
const char *arg = args.at(i);
if (strcmp(arg, "-qdevel") == 0) {
develMode = true;