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>
This commit is contained in:
Mark Charlebois
2015-03-20 19:49:53 -07:00
parent 653c14fcbb
commit 1f84c348fc
@@ -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 {