From 412a0cadadd0825c49c9aa8da3cea63dbadcbf16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Wed, 16 Jun 2021 10:20:37 +0200 Subject: [PATCH] fix: commands execution out of bounds --- image-viewer/src/input.c | 5 +++-- image-viewer/src/main.c | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/image-viewer/src/input.c b/image-viewer/src/input.c index d6ade66..50cf6d7 100644 --- a/image-viewer/src/input.c +++ b/image-viewer/src/input.c @@ -49,7 +49,7 @@ bool commands_register(commands_t * commands, input_type_t type, char filter, .input = {.filter = filter, .type = type}, }; - commands->commands[commands->size++] = command; + commands->commands[commands->count++] = command; return true; } @@ -76,7 +76,7 @@ bool commands_unregister(commands_t * commands, command_t * command) { int16_t commands_execute(commands_t * commands, input_type_t type, char filter, int amount) { int16_t commands_executed = 0; - for (int i = 0; i < commands->size; i++) { + for (int i = 0; i < commands->count; i++) { command_t command = commands->commands[i]; if (command.input.filter == filter && command.input.type == type) { @@ -98,6 +98,7 @@ void commands_update_rotation_encoders(rotation_encoders_t *encoders) { } return; } + uint8_t btns = *(volatile uint8_t*)(encoders->base_address + ROTATION_ENCODERS_COUNT); for (int i = 0; i < ROTATION_ENCODERS_COUNT; i++) { diff --git a/image-viewer/src/main.c b/image-viewer/src/main.c index e8d1545..617695b 100644 --- a/image-viewer/src/main.c +++ b/image-viewer/src/main.c @@ -72,7 +72,6 @@ int main(int argc, char *argv[]) } image_viewer_display_image(&viewer); - image_viewer_start_loop(&viewer, reg_knobs_base); logger_info(&logger, __FILE__, __FUNCTION__, __LINE__, -- 2.48.1