From ed6d4bd495088a4f42abca4b2f78c8f4f097110d Mon Sep 17 00:00:00 2001 From: Stefan Dunca Date: Fri, 28 Jun 2019 17:09:04 +0200 Subject: [PATCH] Fix dangling pointer access --- src/Vehicle/Vehicle.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index fb1e76b..1210666 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -551,8 +551,11 @@ Vehicle::~Vehicle() void Vehicle::prepareDelete() { if(_cameras) { - delete _cameras; + // because of _cameras QML bindings check for nullptr won't work in the binding pipeline + // the dangling pointer access will cause a runtime fault + auto tmpCameras = _cameras; _cameras = nullptr; + delete tmpCameras; emit dynamicCamerasChanged(); qApp->processEvents(); }