From af06737e7e3e536c5043adfc943e4b4600d19e36 Mon Sep 17 00:00:00 2001 From: Julian Oes <julian@oes.ch> Date: Wed, 25 May 2016 21:50:23 +0200 Subject: [PATCH] sdlog2: fix Segfault on Eagle (#4638) Since orb_exist doesn't work on the Snapdragon Linux side, we need to do an additional orb_check after the orb_subscribe_multi, otherwise we copy garbage. The segfault was triggered by a count/length information about ESC packets which lead to access outside the struct in the garbage case. --- src/modules/sdlog2/sdlog2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/modules/sdlog2/sdlog2.c b/src/modules/sdlog2/sdlog2.c index 1c07400fd8..db783325a5 100644 --- a/src/modules/sdlog2/sdlog2.c +++ b/src/modules/sdlog2/sdlog2.c @@ -917,8 +917,13 @@ bool copy_if_updated_multi(orb_id_t topic, int multi_instance, int *handle, void *handle = orb_subscribe_multi(topic, multi_instance); /* copy first data */ if (*handle >= 0) { - orb_copy(topic, *handle, buffer); - updated = true; + + /* but only if it has really been updated */ + orb_check(*handle, &updated); + + if (updated) { + orb_copy(topic, *handle, buffer); + } } } } else { -- GitLab