RC_Channel_aux: catch invalid function settings

a bad function setting would overwrite the heap
This commit is contained in:
Andrew Tridgell 2012-02-13 12:39:16 +11:00
parent 131861b629
commit c6b6898266
1 changed files with 8 additions and 1 deletions

View File

@ -80,8 +80,15 @@ void update_aux_servo_function(RC_Channel_aux* rc_5, RC_Channel_aux* rc_6, RC_Ch
aux_servo_function[CH_7] = (RC_Channel_aux::Aux_servo_function_t)rc_7->function.get();
aux_servo_function[CH_8] = (RC_Channel_aux::Aux_servo_function_t)rc_8->function.get();
for (uint8_t i = 0; i < NUM_CHANNELS; i++) {
if (aux_servo_function[i] >= RC_Channel_aux::k_nr_aux_servo_functions) {
// invalid setting
aux_servo_function[i] = RC_Channel_aux::k_none;
}
}
// Assume that no auxiliary function is used
for (int i = 0; i < RC_Channel_aux::k_nr_aux_servo_functions ; i++)
for (uint8_t i = 0; i < RC_Channel_aux::k_nr_aux_servo_functions ; i++)
{
g_rc_function[i] = NULL;
}