From 92b95e3355ea035f8d2d18eb78dda0835204e7da Mon Sep 17 00:00:00 2001 From: Morton Lin Date: Fri, 30 Oct 2020 03:15:40 +0800 Subject: [PATCH] fix issue of read access violation exception(access nullptr) (#9146) (cherry picked from commit 2faa80dacfa726f1ece6720934e5b5f81ca4b754) --- src/Vehicle/Vehicle.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index b5119d33a..68235b528 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -3729,7 +3729,8 @@ void Vehicle::clearAllParamMapRC(void) void Vehicle::sendJoystickDataThreadSafe(float roll, float pitch, float yaw, float thrust, quint16 buttons) { - if (_vehicleLinkManager->primaryLink()->linkConfiguration()->isHighLatency()) { + LinkInterface* pPrimaryLink = vehicleLinkManager()->primaryLink(); + if (pPrimaryLink == nullptr || pPrimaryLink->linkConfiguration()->isHighLatency()) { return; } @@ -3745,7 +3746,7 @@ void Vehicle::sendJoystickDataThreadSafe(float roll, float pitch, float yaw, flo mavlink_msg_manual_control_pack_chan( static_cast(_mavlink->getSystemId()), static_cast(_mavlink->getComponentId()), - vehicleLinkManager()->primaryLink()->mavlinkChannel(), + pPrimaryLink->mavlinkChannel(), &message, static_cast(_id), static_cast(newPitchCommand), @@ -3753,5 +3754,5 @@ void Vehicle::sendJoystickDataThreadSafe(float roll, float pitch, float yaw, flo static_cast(newThrustCommand), static_cast(newYawCommand), buttons); - sendMessageOnLinkThreadSafe(vehicleLinkManager()->primaryLink(), message); + sendMessageOnLinkThreadSafe(pPrimaryLink, message); } -- 2.22.0