From 1f84c348fcc5a9ce967c8844ddaa9a77421ec2d9 Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Fri, 20 Mar 2015 19:49:53 -0700 Subject: [PATCH] fix for segv if topic has not been published If the topic has not been published, orb_copy returns a negative number which causes update() to memset the data contents to zero. In some instances data is a null pointer. This causes a segment violation crash. Added a check for data != 0 Signed-off-by: Mark Charlebois --- src/modules/mavlink/mavlink_orb_subscription.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/mavlink/mavlink_orb_subscription.cpp b/src/modules/mavlink/mavlink_orb_subscription.cpp index 0050ec9fd4..4567f4f410 100644 --- a/src/modules/mavlink/mavlink_orb_subscription.cpp +++ b/src/modules/mavlink/mavlink_orb_subscription.cpp @@ -86,8 +86,10 @@ MavlinkOrbSubscription::update(uint64_t *time, void* data) } if (orb_copy(_topic, _fd, data)) { - /* error copying topic data */ - memset(data, 0, _topic->o_size); + if (data) { + /* error copying topic data */ + memset(data, 0, _topic->o_size); + } return false; } else {