From 448cdb7bb5ec58f55ea5065de5325e1be9eaf238 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 30 Nov 2020 13:09:39 +0100 Subject: [PATCH] Fix a crash when editing cpp file std::mismach() overload taking 3 arg assumes, that second string is at least as long as the first one. We don't guarantee this, as somethimes filePath2 is empty string. Use 4 arg overload instead, which ensure we don't exceed the valid range. Fixes: QTCREATORBUG-24970 Change-Id: I8b7b11d124f69c7c9cb3246ee969f134fa026e08 Reviewed-by: hjk --- src/plugins/cpptools/cppfileiterationorder.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/cpptools/cppfileiterationorder.cpp b/src/plugins/cpptools/cppfileiterationorder.cpp index dd040e99763..806a73b25d8 100644 --- a/src/plugins/cpptools/cppfileiterationorder.cpp +++ b/src/plugins/cpptools/cppfileiterationorder.cpp @@ -108,9 +108,8 @@ bool FileIterationOrder::isValid() const static int commonPrefixLength(const QString &filePath1, const QString &filePath2) { - const auto mismatches = std::mismatch(filePath1.begin(), - filePath1.end(), - filePath2.begin()); + const auto mismatches = std::mismatch(filePath1.begin(), filePath1.end(), + filePath2.begin(), filePath2.end()); return mismatches.first - filePath1.begin(); }