diff --git a/canard/service_client.h b/canard/service_client.h index bca543f..8997e78 100644 --- a/canard/service_client.h +++ b/canard/service_client.h @@ -68,7 +68,9 @@ class Client : public HandlerList, public Sender { /// @param transfer transfer object of the request void handle_message(const CanardRxTransfer& transfer) override { rsptype msg {}; - rsptype::cxx_iface::rsp_decode(&transfer, &msg); + if (!rsptype::cxx_iface::rsp_decode(&transfer, &msg)) { + return; + } // scan through the list of entries for corresponding server node id and transfer id Client* entry = branch_head[index]; diff --git a/canard/service_server.h b/canard/service_server.h index bfc7b39..9e6dbb5 100644 --- a/canard/service_server.h +++ b/canard/service_server.h @@ -51,7 +51,9 @@ class Server : public HandlerList { /// @param transfer transfer object of the request void handle_message(const CanardRxTransfer& transfer) override { reqtype msg {}; - reqtype::cxx_iface::req_decode(&transfer, &msg); + if (!reqtype::cxx_iface::req_decode(&transfer, &msg)) { + return; + } transfer_id = transfer.transfer_id; // call the registered callback cb(transfer, msg); diff --git a/canard/subscriber.h b/canard/subscriber.h index 52f1598..c53de2c 100644 --- a/canard/subscriber.h +++ b/canard/subscriber.h @@ -71,7 +71,9 @@ class Subscriber : public HandlerList { /// @param transfer transfer object void handle_message(const CanardRxTransfer& transfer) override { msgtype msg {}; - msgtype::cxx_iface::decode(&transfer, &msg); + if (!msgtype::cxx_iface::decode(&transfer, &msg)) { + return; + } // call all registered callbacks in one go Subscriber* entry = branch_head[index]; while (entry != nullptr) {