Browse Source

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 <charlebm@gmail.com>
sbg
Mark Charlebois 10 years ago
parent
commit
1f84c348fc
  1. 6
      src/modules/mavlink/mavlink_orb_subscription.cpp

6
src/modules/mavlink/mavlink_orb_subscription.cpp

@ -86,8 +86,10 @@ MavlinkOrbSubscription::update(uint64_t *time, void* data) @@ -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 {

Loading…
Cancel
Save