diff --git a/applications/debug/uart_echo/uart_echo.c b/applications/debug/uart_echo/uart_echo.c index 0291c9e79..9c65910a0 100644 --- a/applications/debug/uart_echo/uart_echo.c +++ b/applications/debug/uart_echo/uart_echo.c @@ -283,13 +283,14 @@ static UartEchoApp* uart_echo_app_alloc(uint32_t baudrate) { static void uart_echo_app_free(UartEchoApp* app) { furi_assert(app); + furi_hal_serial_async_rx_stop(app->serial_handle); + furi_hal_serial_deinit(app->serial_handle); + furi_hal_serial_control_release(app->serial_handle); + furi_thread_flags_set(furi_thread_get_id(app->worker_thread), WorkerEventStop); furi_thread_join(app->worker_thread); furi_thread_free(app->worker_thread); - furi_hal_serial_deinit(app->serial_handle); - furi_hal_serial_control_release(app->serial_handle); - // Free views view_dispatcher_remove_view(app->view_dispatcher, 0); diff --git a/applications/services/gui/modules/text_box.c b/applications/services/gui/modules/text_box.c index c0110806a..ff728108f 100644 --- a/applications/services/gui/modules/text_box.c +++ b/applications/services/gui/modules/text_box.c @@ -102,9 +102,11 @@ static void text_box_insert_endline(Canvas* canvas, TextBoxModel* model) { model->text_pos = (char*)model->text; if(model->focus == TextBoxFocusEnd && line_num > 5) { // Set text position to 5th line from the end - for(uint8_t i = 0; i < line_num - 5; i++) { - while(*model->text_pos++ != '\n') { - }; + const char* end = model->text + furi_string_size(model->text_formatted); + for(size_t i = 0; i < line_num - 5; i++) { + while(model->text_pos < end) { + if(*model->text_pos++ == '\n') break; + } } model->scroll_num = line_num - 4; model->scroll_pos = line_num - 5;