From b8022413b3ced2b19cbe24f41930a354ef8a634e Mon Sep 17 00:00:00 2001 From: boerge1 Date: Tue, 19 Sep 2023 18:48:21 +0200 Subject: [PATCH] Issue_111: TonUINO crashes if if the player gives a track count >255 --- README.md | 5 +++-- TonUINO-TNG.ino | 2 +- src/mp3.cpp | 2 ++ test/src/mp3_tests.cpp | 15 +++++++++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f98ea69..69a902f 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,11 @@ Die SD Karte (Ordner mp3 und advert) hat sich gegenüber der Version 3.1.2 geän # Change Log +## Version 3.1.4 (19.09.2023) +- [Issue 111](https://github.com/tonuino/TonUINO-TNG/issues/111): TonUINO crashes if if the player gives a track count >255 + ## Version 3.1.4 (17.09.2023) - [Issue 108](https://github.com/tonuino/TonUINO-TNG/issues/108): Missing OnPlayFinished: the progress is not saved for Hoerbuch mode - -## Version 3.1.4 (14.09.2023) - [Issue 106](https://github.com/tonuino/TonUINO-TNG/issues/106): Support LISP3 DF Player - [Issue 100](https://github.com/tonuino/TonUINO-TNG/issues/100): Support Nano Every with classic HW - [Issue 104](https://github.com/tonuino/TonUINO-TNG/issues/104): Use bad framework-lgt8fx diff --git a/TonUINO-TNG.ino b/TonUINO-TNG.ino index 9f90f2f..5ce3fa6 100644 --- a/TonUINO-TNG.ino +++ b/TonUINO-TNG.ino @@ -35,7 +35,7 @@ void setup() LOG(init_log, s_error, F("TonUINO Version 3.1 - refactored by Boerge1\n")); LOG(init_log, s_error, F("created by Thorsten Voß and licensed under GNU/GPL.")); LOG(init_log, s_error, F("Information and contribution at https://tonuino.de.\n")); - LOG(init_log, s_error, F("V3.1.4 17.09.23\n")); + LOG(init_log, s_error, F("V3.1.4 19.09.23\n")); Tonuino::getTonuino().setup(); } diff --git a/src/mp3.cpp b/src/mp3.cpp index 977a15c..4610a44 100644 --- a/src/mp3.cpp +++ b/src/mp3.cpp @@ -124,6 +124,8 @@ void Mp3::enqueueTrack(uint8_t folder, uint8_t firstTrack, uint8_t lastTrack, ui for (uint8_t i = firstTrack; i<=lastTrack; ++i) { LOG(mp3_log, s_info, i, str_Space(), lf_no); q.push(i); + if (i == 0xffu) + break; } LOG(mp3_log, s_info, str_Space()); current_track = currentTrack; diff --git a/test/src/mp3_tests.cpp b/test/src/mp3_tests.cpp index 76de84c..c2d64b0 100644 --- a/test/src/mp3_tests.cpp +++ b/test/src/mp3_tests.cpp @@ -99,6 +99,21 @@ TEST_F(mp3_test_fixture, enqueue_folder_tracks) { EXPECT_TRUE(mp3.is_stopped()); } +TEST_F(mp3_test_fixture, enqueue_folder_tracks_no_chrash) { + mp3.enqueueTrack(1, 2, 255); + execute_cycle(); + + for (uint16_t t = 2; t <= 255; ++t) { + EXPECT_TRUE(mp3.is_playing_folder()); + EXPECT_EQ(mp3.df_folder, 1); + EXPECT_EQ(mp3.df_folder_track, t); + mp3.end_track(); + execute_cycle(); + execute_cycle(); + } + EXPECT_TRUE(mp3.is_stopped()); +} + TEST_F(mp3_test_fixture, enqueue_folder_tracks_with_current) { mp3.enqueueTrack(1, 2, 12, 3); execute_cycle();