keyboard: Avoid access beyond end off buffer

If the for loop does not match on a button it will fall through and try and
dereference into the array using the terminating value of the loop. This
terminating value of the loop is the dimension of the array and thus beyond
its bounds.

Cc: Jan Arne Petersen <jpetersen@openismus.com>
Signed-off-by: Rob Bradford <rob@linux.intel.com>
This commit is contained in:
Rob Bradford 2012-10-09 18:44:34 +01:00 committed by Kristian Høgsberg
parent 273fec8ede
commit 053fe7652b
1 changed files with 3 additions and 3 deletions

View File

@ -313,12 +313,12 @@ button_handler(struct widget *widget,
col = x / key_width + row * columns;
for (i = 0; i < sizeof(keys) / sizeof(*keys); ++i) {
col -= keys[i].width;
if (col < 0)
if (col < 0) {
keyboard_handle_key(keyboard, &keys[i]);
break;
}
}
keyboard_handle_key(keyboard, &keys[i]);
widget_schedule_redraw(widget);
}