23 lines
1.4 KiB
Diff
23 lines
1.4 KiB
Diff
# UNDF: UNDF-2026-000000800
|
|
# UNDF: (leave blank)
|
|
# Defect: kdenlive-0003
|
|
# Component: src/timeline2/view/timelinecontroller.cpp — moveGroup
|
|
# Pattern: CWE-407 — sorted_clips vector<int> scanned with std::find inside per-clip loop
|
|
# Severity: MEDIUM — O(N^2) where N = grouped clips being moved
|
|
# Fix: Build unordered_set from sorted_clips for O(1) membership test
|
|
--- a/src/timeline2/view/timelinecontroller.cpp
|
|
+++ b/src/timeline2/view/timelinecontroller.cpp
|
|
@@ -4638,6 +4638,7 @@
|
|
std::vector<int> sorted_clips{std::make_move_iterator(std::begin(all_items)), std::make_move_iterator(std::end(all_items))};
|
|
std::sort(sorted_clips.begin(), sorted_clips.end(), [this](const int &clipId1, const int &clipId2) {
|
|
...
|
|
});
|
|
+ std::unordered_set<int> sorted_clips_set(sorted_clips.begin(), sorted_clips.end());
|
|
...
|
|
for (int item : sorted_clips) {
|
|
@@ -4673,7 +4674,7 @@
|
|
- if (std::find(sorted_clips.begin(), sorted_clips.end(), mixData.first.firstClipId) == sorted_clips.end()) {
|
|
+ if (sorted_clips_set.count(mixData.first.firstClipId) == 0) {
|
|
@@ -4685,7 +4686,7 @@
|
|
- if (mixData.second.firstClipId > -1 && std::find(sorted_clips.begin(), sorted_clips.end(), mixData.second.secondClipId) == sorted_clips.end()) {
|
|
+ if (mixData.second.firstClipId > -1 && sorted_clips_set.count(mixData.second.secondClipId) == 0) {
|