From b28d408b49cdb18543c08eaebd6877f3c798303f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Sat, 23 Apr 2022 04:56:59 +0300 Subject: [PATCH] [FL-2493] Infrared: fix crash on invalid name. Input: cancel info in dump command. (#1153) * Infrared: fix crash on invalid name. Input: cancel info in dump command. * FuriHal: add abort handler --- applications/infrared/infrared_app.cpp | 19 +++++++++++-------- applications/input/input_cli.c | 8 ++------ firmware/targets/f7/Src/main.c | 4 ++++ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/applications/infrared/infrared_app.cpp b/applications/infrared/infrared_app.cpp index 64bdb2b2..c9a7ee4f 100644 --- a/applications/infrared/infrared_app.cpp +++ b/applications/infrared/infrared_app.cpp @@ -14,14 +14,17 @@ int32_t InfraredApp::run(void* args) { if(args) { std::string path = static_cast(args); std::string remote_name(path, path.find_last_of('/') + 1, path.size()); - remote_name.erase(remote_name.find_last_of('.')); - path.erase(path.find_last_of('/')); - bool result = remote_manager.load(path, remote_name); - if(result) { - current_scene = InfraredApp::Scene::Remote; - } else { - printf("Failed to load remote \'%s\'\r\n", remote_name.c_str()); - return -1; + auto last_dot = remote_name.find_last_of('.'); + if(last_dot != std::string::npos) { + remote_name.erase(last_dot); + path.erase(path.find_last_of('/')); + bool result = remote_manager.load(path, remote_name); + if(result) { + current_scene = InfraredApp::Scene::Remote; + } else { + printf("Failed to load remote \'%s\'\r\n", remote_name.c_str()); + return -1; + } } } diff --git a/applications/input/input_cli.c b/applications/input/input_cli.c index eb510f6c..00591a75 100644 --- a/applications/input/input_cli.c +++ b/applications/input/input_cli.c @@ -24,19 +24,15 @@ static void input_cli_dump(Cli* cli, string_t args, Input* input) { FuriPubSubSubscription* input_subscription = furi_pubsub_subscribe(input->event_pubsub, input_cli_dump_events_callback, input_queue); - bool stop = false; InputEvent input_event; - while(!stop) { + printf("Press CTRL+C to stop\r\n"); + while(!cli_cmd_interrupt_received(cli)) { if(osMessageQueueGet(input_queue, &input_event, NULL, 100) == osOK) { printf( "key: %s type: %s\r\n", input_get_key_name(input_event.key), input_get_type_name(input_event.type)); } - - if(cli_cmd_interrupt_received(cli)) { - stop = true; - } } furi_pubsub_unsubscribe(input->event_pubsub, input_subscription); diff --git a/firmware/targets/f7/Src/main.c b/firmware/targets/f7/Src/main.c index 759626a2..1865f8d1 100644 --- a/firmware/targets/f7/Src/main.c +++ b/firmware/targets/f7/Src/main.c @@ -65,6 +65,10 @@ void Error_Handler(void) { furi_crash("ErrorHandler"); } +void abort() { + furi_crash("AbortHandler"); +} + #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number