From a96a33d993618d5326e16ffb1b5028a94ceb4af2 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 17 May 2019 09:12:45 +0200 Subject: 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 --- src/winmain/qtmain_winrt.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/winmain/qtmain_winrt.cpp') diff --git a/src/winmain/qtmain_winrt.cpp b/src/winmain/qtmain_winrt.cpp index 7cc57f4d46..1828c4ca16 100644 --- a/src/winmain/qtmain_winrt.cpp +++ b/src/winmain/qtmain_winrt.cpp @@ -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; -- cgit v1.2.3