forked from qt-creator/qt-creator
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 <hjk@qt.io>
This commit is contained in:
@@ -108,9 +108,8 @@ bool FileIterationOrder::isValid() const
|
|||||||
|
|
||||||
static int commonPrefixLength(const QString &filePath1, const QString &filePath2)
|
static int commonPrefixLength(const QString &filePath1, const QString &filePath2)
|
||||||
{
|
{
|
||||||
const auto mismatches = std::mismatch(filePath1.begin(),
|
const auto mismatches = std::mismatch(filePath1.begin(), filePath1.end(),
|
||||||
filePath1.end(),
|
filePath2.begin(), filePath2.end());
|
||||||
filePath2.begin());
|
|
||||||
return mismatches.first - filePath1.begin();
|
return mismatches.first - filePath1.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user