Skip to content

Commit

Permalink
Avoid non-Teensy boards in ty_board_identify
Browse files Browse the repository at this point in the history
Use the vtable to determine if a model is indeed a Teensy one. Testing
non-Teensy models using Teensy-specific fields would be at best just
non-sense, at worst a very intermittent and annoying segmentation fault.
  • Loading branch information
Koromix committed Dec 21, 2014
1 parent 14dc9a6 commit c088624
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/board_teensy.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,12 @@ static int teensy_identify(ty_board *board)

board->model = NULL;
for (const ty_board_model **cur = ty_board_models; *cur; cur++) {
if ((*cur)->usage == desc.usage) {
const ty_board_model *model = *cur;

if (model->vtable != &teensy_model_vtable)
continue;

if (model->usage == desc.usage) {
board->model = *cur;
break;
}
Expand Down

0 comments on commit c088624

Please sign in to comment.