From 2295e82a0f7b2cdfceafdc8df15dfe76cab828e2 Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 14 Aug 2020 22:41:18 +0100 Subject: [PATCH] Fix a use-after-free found by ASan. --- src/Instrumentation/gps.cxx | 9 +++++++++ src/Instrumentation/gps.hxx | 1 + 2 files changed, 10 insertions(+) diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx index 9a3470680..471089a53 100644 --- a/src/Instrumentation/gps.cxx +++ b/src/Instrumentation/gps.cxx @@ -267,6 +267,7 @@ void GPS::unbind() { _tiedProperties.Untie(); + _gpsNode.clear(); } void @@ -366,6 +367,14 @@ GPS::update (double delta_time_sec) _lastPosValid = !(_last_pos == SGGeod()); } +void GPS::shutdown() +{ + if (_route) { + _route->removeDelegate(this); + _route = nullptr; + } +} + void GPS::routeManagerFlightPlanChanged(SGPropertyNode*) { if (_route) { diff --git a/src/Instrumentation/gps.hxx b/src/Instrumentation/gps.hxx index 200499eb7..7e0ca3832 100644 --- a/src/Instrumentation/gps.hxx +++ b/src/Instrumentation/gps.hxx @@ -70,6 +70,7 @@ public: void bind() override; void unbind() override; void update (double delta_time_sec) override; + void shutdown() override; // Subsystem identification. static const char* staticSubsystemClassId() { return "gps"; }