From b2ea28c79eb633bbccf7c3c44a0a9889fe2b7091 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 24 Jan 2017 08:40:32 +0100 Subject: fix crash by guarding QString::setRawData QString::lastIndexOf can return a -1 if the pattern was not found. Using a QString that was created by QString::setRawData with a size of -1 will result in a crash. Change-Id: Ie02645f00db7e7150424ca367095a7ebc9051578 Reviewed-by: Oswald Buddenhagen --- src/shared/proparser/profileevaluator.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/shared') diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp index 99f4fe0262..60319672a4 100644 --- a/src/shared/proparser/profileevaluator.cpp +++ b/src/shared/proparser/profileevaluator.cpp @@ -152,6 +152,10 @@ QVector ProFileEvaluator::absoluteFileValues( } { int nameOff = absEl.lastIndexOf(QLatin1Char('/')); + if (nameOff < 0) { + // The entry is garbage (possibly after env var expansion) + goto next; + } QString absDir = d->m_tmp1.setRawData(absEl.constData(), nameOff); if (IoUtils::exists(absDir)) { QString wildcard = d->m_tmp2.setRawData(absEl.constData() + nameOff + 1, -- cgit v1.2.3