Skip to content

Fix tone partition index and update the (AUD-6237) #1422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion components/audio_stream/tone_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include "tone_stream.h"
#include <inttypes.h>

#define DEFAULT_TONE_NUM 4

static const char *TAG = "TONE_STREAM";

/**
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion components/tone_partition/tone_partition.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down