Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.12.3, 5.13.0 Beta3, 5.14
-
None
-
-
a96a33d993618d5326e16ffb1b5028a94ceb4af2 (qt/qtbase/5.12)
Description
UWP apps sometimes crash when they come to foreground (from background). The crash is caused by the fact that the variable "args" can contain NULL entries (e.g. args.at( i ) == NULL) which causes a crash in "str*cmp". The following code fixes the problem by checking the elements for NULL first:
//qtmain_winrt.cpp bool quote = false; bool escape = false; for (int i = 0; i < commandLine.size(); ++i) { switch (commandLine.at(i)) { case '\\': escape = true; break; case '"': if (escape) { escape = false; break; } quote = !quote; commandLine[i] = '\0'; break; case ' ': if (quote) break; commandLine[i] = '\0'; if (!args.isEmpty() && args.last() && args.last()[0] != '\0') args.append(commandLine.data() + i + 1); // fall through default: 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 && 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; args.remove(i); } else if (strcmp(arg, "-qdebug") == 0) { debugWait = true; args.remove(i); } } args.append(nullptr);
Attachments
For Gerrit Dashboard: QTBUG-75843 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
262034,2 | qtmain_winrt: Avoid nullptrs in str*cmp which cause crashes | 5.12 | qt/qtbase | Status: MERGED | +2 | 0 |