diff --git a/components/audio_stream/tone_stream.c b/components/audio_stream/tone_stream.c index 157412fea..7484a54a8 100644 --- a/components/audio_stream/tone_stream.c +++ b/components/audio_stream/tone_stream.c @@ -34,6 +34,8 @@ #include "tone_stream.h" #include +#define DEFAULT_TONE_NUM 4 + static const char *TAG = "TONE_STREAM"; /** @@ -64,7 +66,7 @@ static esp_err_t _tone_open(audio_element_handle_t self) flash_url += strlen("flash://tone/"); char *temp = strchr(flash_url, '_'); - char find_num[2] = { 0 }; + char find_num[DEFAULT_TONE_NUM] = {0}; int file_index = 0; if (temp != NULL) { strncpy(find_num, flash_url, temp - flash_url); diff --git a/components/tone_partition/tone_partition.c b/components/tone_partition/tone_partition.c index 5c08ee0d4..b4e62f8ed 100644 --- a/components/tone_partition/tone_partition.c +++ b/components/tone_partition/tone_partition.c @@ -92,7 +92,7 @@ esp_err_t tone_partition_get_file_info(tone_partition_handle_t handle, uint16_t AUDIO_NULL_CHECK(TAG, handle, return ESP_FAIL); AUDIO_NULL_CHECK(TAG, info, return ESP_FAIL); - if (handle->header.total_num < index) { + if (handle->header.total_num <= index) { ESP_LOGE(TAG, "Wanted index out of range index[%d]", index); return ESP_FAIL; }