[plasma/plasma-desktop/Plasma/6.7] kcms/gamecontroller: kcms/gamecontroller: Fix std::out_of_range exception
Méven Car <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit ed508fbc7b39dba3369f57858b07fdb921e9e8b6 by Méven Car. Committed on 20/07/2026 at 09:59. Pushed by meven into branch 'Plasma/6.7'. kcms/gamecontroller: Fix std::out_of_range exception If either slash==std::string::npos or devicePath.empty() then the code can throw a std::out_of_range exception. Fix that and make sure the code not throws a std::out_of_range exception. Based on a patch done by Adam Doda. BUG: 522886 (cherry picked from commit 932f29636ccd264005cb1af579c0c1a11976cbf7) Co-authored-by: Sebastian Sauer <[email protected]> M +1 -1 kcms/gamecontroller/udevmatcher.cpp https://invent.kde.org/plasma/plasma-desktop/-/commit/ed508fbc7b39dba3369f57858b07fdb921e9e8b6 diff --git a/kcms/gamecontroller/udevmatcher.cpp b/kcms/gamecontroller/udevmatcher.cpp index 24febd0291..794119336c 100644 --- a/kcms/gamecontroller/udevmatcher.cpp +++ b/kcms/gamecontroller/udevmatcher.cpp @@ -52,7 +52,7 @@ std::string UDevMatcher::deviceToUdevId(const std::string &device_path) qCDebug(KCM_GAMECONTROLLER) << "Looking for ID of " << devicePath; // If the bit after the last / is a digit, stop, we found it - while (!std::isdigit(devicePath.at(slash + 1))) { + while (slash != std::string::npos && (slash + 1) < devicePath.length() && !std::isdigit(devicePath.at(slash + 1))) { // Remove the last bit devicePath = devicePath.substr(0, slash);