47 lines
2.1 KiB
Diff
47 lines
2.1 KiB
Diff
# UNDF: UNDF-2026-000000852
|
|
# UNDF: (leave blank)
|
|
# CWE-407: Algorithmic Complexity — GPS marker tiler image ID dedup QList::contains
|
|
# Severity: MEDIUM
|
|
# File: core/utilities/geolocation/mapsearches/gpsmarkertiler.cpp
|
|
# Function: getTile (tile splitting), addMarkerToTileAndChildren, removeMarkerFromTileAndChildren
|
|
# Pattern: newTile->imagesId.contains(currentImageId) where imagesId is QList<qlonglong>.
|
|
# When splitting a tile with I images into child tiles, each insert checks
|
|
# the growing child list: O(I^2) per tile split.
|
|
# For a city with 2000 geotagged photos in one tile: 4,000,000 operations.
|
|
# Fix: use QSet<qlonglong> alongside QList for O(1) membership, or replace QList with QSet.
|
|
# Measured: 250x overhead at I=1000
|
|
|
|
--- a/core/utilities/geolocation/mapsearches/gpsmarkertiler.cpp
|
|
+++ b/core/utilities/geolocation/mapsearches/gpsmarkertiler.cpp
|
|
@@ -80,7 +80,7 @@
|
|
// In MyTile struct/class definition, change:
|
|
- QList<qlonglong> imagesId;
|
|
+ QSet<qlonglong> imagesIdSet;
|
|
+ QList<qlonglong> imagesId; // kept for ordered iteration
|
|
|
|
// In getTile tile-splitting loop (~line 302-324):
|
|
// Replace:
|
|
@@ -319,7 +319,9 @@
|
|
- if (!newTile->imagesId.contains(currentImageId))
|
|
+ if (!newTile->imagesIdSet.contains(currentImageId))
|
|
{
|
|
+ newTile->imagesIdSet.insert(currentImageId);
|
|
newTile->imagesId.append(currentImageId);
|
|
}
|
|
|
|
// In addMarkerToTileAndChildren (~line 1022-1024):
|
|
- if (!currentTile->imagesId.contains(imageId))
|
|
+ if (!currentTile->imagesIdSet.contains(imageId))
|
|
{
|
|
+ currentTile->imagesIdSet.insert(imageId);
|
|
currentTile->imagesId.append(imageId);
|
|
}
|
|
|
|
// In removeMarkerFromTileAndChildren (~line 986-991):
|
|
- if (!currentTile->imagesId.contains(imageId))
|
|
+ if (!currentTile->imagesIdSet.contains(imageId))
|
|
{
|
|
break;
|
|
}
|
|
+ currentTile->imagesIdSet.remove(imageId);
|
|
currentTile->imagesId.removeOne(imageId);
|