diff --git a/applications/debug/unit_tests/storage/storage_test.c b/applications/debug/unit_tests/storage/storage_test.c index c3628a4f9..099be0d5c 100644 --- a/applications/debug/unit_tests/storage/storage_test.c +++ b/applications/debug/unit_tests/storage/storage_test.c @@ -58,7 +58,7 @@ MU_TEST(storage_file_open_lock) { storage_file_close(file); // file_locker thread stop - mu_check(furi_thread_join(locker_thread) == FuriStatusOk); + mu_check(furi_thread_join(locker_thread)); furi_thread_free(locker_thread); // clean data @@ -148,7 +148,7 @@ MU_TEST(storage_dir_open_lock) { storage_dir_close(file); // file_locker thread stop - mu_check(furi_thread_join(locker_thread) == FuriStatusOk); + mu_check(furi_thread_join(locker_thread)); furi_thread_free(locker_thread); // clean data diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_write.c b/applications/main/lfrfid/scenes/lfrfid_scene_write.c index 4b03bac15..8e791d529 100644 --- a/applications/main/lfrfid/scenes/lfrfid_scene_write.c +++ b/applications/main/lfrfid/scenes/lfrfid_scene_write.c @@ -38,7 +38,6 @@ void lfrfid_scene_write_on_enter(void* context) { view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup); size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id); - app->old_key_data = (uint8_t*)malloc(size); protocol_dict_get_data(app->dict, app->protocol_id, app->old_key_data, size); lfrfid_worker_start_thread(app->lfworker); @@ -92,5 +91,4 @@ void lfrfid_scene_write_on_exit(void* context) { size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id); protocol_dict_set_data(app->dict, app->protocol_id, app->old_key_data, size); - free(app->old_key_data); } diff --git a/furi/core/thread.c b/furi/core/thread.c index d326e389b..d06fa8b36 100644 --- a/furi/core/thread.c +++ b/furi/core/thread.c @@ -93,14 +93,16 @@ static void furi_thread_body(void* context) { thread->name ? thread->name : ""); } - // clear thread local storage + // flush stdout __furi_thread_stdout_flush(thread); - furi_assert(pvTaskGetThreadLocalStoragePointer(NULL, 0) != NULL); - vTaskSetThreadLocalStoragePointer(NULL, 0, NULL); // from here we can't use thread pointer furi_thread_set_state(thread, FuriThreadStateStopped); + // clear thread local storage + furi_assert(pvTaskGetThreadLocalStoragePointer(NULL, 0) != NULL); + vTaskSetThreadLocalStoragePointer(NULL, 0, NULL); + vTaskDelete(NULL); furi_thread_catch(); }