Blimp: avoid nullptr dereference on bad rcmap value entry

This commit is contained in:
Peter Barker 2024-09-08 00:22:49 +10:00 committed by Peter Barker
parent 9be4cc65c7
commit a868fb8861
1 changed files with 5 additions and 4 deletions

View File

@ -15,10 +15,11 @@ void Blimp::default_dead_zones()
void Blimp::init_rc_in() void Blimp::init_rc_in()
{ {
channel_right = rc().channel(rcmap.roll()-1); // the library gaurantees that these are non-nullptr:
channel_front = rc().channel(rcmap.pitch()-1); channel_right = &rc().get_roll_channel();
channel_up = rc().channel(rcmap.throttle()-1); channel_front = &rc().get_pitch_channel();
channel_yaw = rc().channel(rcmap.yaw()-1); channel_up = &rc().get_throttle_channel();
channel_yaw = &rc().get_yaw_channel();
// set rc channel ranges // set rc channel ranges
channel_right->set_angle(RC_SCALE); channel_right->set_angle(RC_SCALE);