┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemrange.h
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2014-06-04 21:48:19 +0200
committerFrank Reininghaus <[email protected]>2014-06-04 21:49:02 +0200
commit352f6441590a050099ee685b2284d1679f733c97 (patch)
treee9547883bc442b94569496931b3e22b5c0689fa7 /src/kitemviews/kitemrange.h
parent96c34cfe650cef24bcfd6cfa6977c3b0ccb77281 (diff)
Fix possible crash if a kioslave adds multiple items with the same URL
When opening the URL "man:", there are multiple items with the same name (for example, _exit is shown twice here). When opening a new tab, the kioslave reports some items as deleted (I have not quite understood why). The problem is that it reports some of the duplicate items twice in the list of deleted items. This confused KFileItemModel and corrupted the internal data structures, and finally, caused a crash. The fix is to remove all duplicates from KItemRangeList::fromSortedContainer(const Container& container). New unit tests included. BUG: 335672 REVIEW: 118507 FIXED-IN: 4.13.2
Diffstat (limited to 'src/kitemviews/kitemrange.h')
-rw-r--r--src/kitemviews/kitemrange.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/kitemviews/kitemrange.h b/src/kitemviews/kitemrange.h
index 70927b915..ecc03988d 100644
--- a/src/kitemviews/kitemrange.h
+++ b/src/kitemviews/kitemrange.h
@@ -78,7 +78,10 @@ KItemRangeList KItemRangeList::fromSortedContainer(const Container& container)
int index = *it;
int count = 1;
- ++it;
+ // Remove duplicates, see https://bugs.kde.org/show_bug.cgi?id=335672
+ while (it != end && *it == index) {
+ ++it;
+ }
while (it != end) {
if (*it == index + count) {
@@ -89,6 +92,11 @@ KItemRangeList KItemRangeList::fromSortedContainer(const Container& container)
count = 1;
}
++it;
+
+ // Remove duplicates, see https://bugs.kde.org/show_bug.cgi?id=335672
+ while (it != end && *it == *(it - 1)) {
+ ++it;
+ }
}
result << KItemRange(index, count);