mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-24 16:05:35 +08:00
Fix segfault if number is bigger than size of airports
This commit is contained in:
committed by
Klaus Basan
parent
f3f3ebc306
commit
bd222f3c97
@@ -12,6 +12,7 @@
|
||||
#include <XPLM/XPLMPlanes.h>
|
||||
#include <XPLM/XPLMUtilities.h>
|
||||
#include "blackmisc/simulation/xplane/qtfreeutils.h"
|
||||
#include <algorithm>
|
||||
|
||||
// clazy:excludeall=reserve-candidates
|
||||
|
||||
@@ -684,6 +685,8 @@ namespace XSwiftBus
|
||||
return calculateGreatCircleDistance(a, ref) < calculateGreatCircleDistance(b, ref);
|
||||
};
|
||||
|
||||
number = std::min(static_cast<int>(m_airports.size()), number);
|
||||
|
||||
auto closestAirports = m_airports;
|
||||
std::partial_sort(closestAirports.begin(), closestAirports.begin() + number, closestAirports.end(), compareFunction);
|
||||
closestAirports.resize(number);
|
||||
|
||||
Reference in New Issue
Block a user