diff --git a/doc/html/changelog.html b/doc/html/changelog.html
index d4a76045..48592240 100644
--- a/doc/html/changelog.html
+++ b/doc/html/changelog.html
@@ -67,7 +67,7 @@
FLAC format:
- - (none)
+ - The lead-out track number for non-CDDA cuesheets now must be 255.
@@ -81,12 +81,13 @@
- Added a new option --no-utf8-convert which works like it does in metaflac (SF #973740).
- Fixed bug where using --replay-gain without any padding option caused only a small PADDING block to be created (SF #1760790).
+ - Fixed bug where importing non-CDDA cuesheets would cause an invalid lead-out track number (SF #1764105).
metaflac:
- - (none)
+ - Fixed bug where importing non-CDDA cuesheets would cause an invalid lead-out track number (SF #1764105).
diff --git a/doc/html/format.html b/doc/html/format.html
index e70ba1a2..2a80ef02 100644
--- a/doc/html/format.html
+++ b/doc/html/format.html
@@ -790,7 +790,7 @@
<8>
- The number of tracks. For CD-DA, this number must be no more than 100 (99 regular tracks and one leadout track).
+ The number of tracks. Must be at least 1 (because of the requisite lead-out track). For CD-DA, this number must be no more than 100 (99 regular tracks and one lead-out track).
|
@@ -798,7 +798,7 @@
CUESHEET_TRACK+
|
- One or more tracks. A CUESHEET block is required to have a lead-out track; it is always the last track in the CUESHEET. For CD-DA, the lead-out track number must be 170 as specified by the Red Book.
+ One or more tracks. A CUESHEET block is required to have a lead-out track; it is always the last track in the CUESHEET. For CD-DA, the lead-out track number must be 170 as specified by the Red Book, otherwise is must be 255.
|
@@ -828,7 +828,7 @@
<8>
- Track number. A track number of 0 is not allowed to avoid conflicting with the CD-DA spec, which reserves this for the lead-in. For CD-DA the number must be 1-99, or 170 for the lead-out. It is not required but encouraged to start with track 1 and increase sequentially. Track numbers must be unique within a CUESHEET.
+ Track number. A track number of 0 is not allowed to avoid conflicting with the CD-DA spec, which reserves this for the lead-in. For CD-DA the number must be 1-99, or 170 for the lead-out; for non-CD-DA, the track number must for 255 for the lead-out. It is not required but encouraged to start with track 1 and increase sequentially. Track numbers must be unique within a CUESHEET.
|
diff --git a/src/share/grabbag/cuesheet.c b/src/share/grabbag/cuesheet.c
index e5215525..03f7cdaa 100644
--- a/src/share/grabbag/cuesheet.c
+++ b/src/share/grabbag/cuesheet.c
@@ -398,9 +398,21 @@ static FLAC__bool local__cuesheet_parse_(FILE *file, const char **error_message,
*error_message = "TRACK number must be greater than 0";
return false;
}
- if(is_cdda && in_track_num > 99) {
- *error_message = "CD-DA TRACK number must be between 1 and 99, inclusive";
- return false;
+ if(is_cdda) {
+ if(in_track_num > 99) {
+ *error_message = "CD-DA TRACK number must be between 1 and 99, inclusive";
+ return false;
+ }
+ }
+ else {
+ if(in_track_num == 255) {
+ *error_message = "TRACK number 255 is reserved for the lead-out";
+ return false;
+ }
+ else if(in_track_num > 255) {
+ *error_message = "TRACK number must be between 1 and 254, inclusive";
+ return false;
+ }
}
if(is_cdda && cs->num_tracks > 0 && in_track_num != cs->tracks[cs->num_tracks-1].number + 1) {
*error_message = "CD-DA TRACK numbers must be sequential";
@@ -503,7 +515,7 @@ static FLAC__bool local__cuesheet_parse_(FILE *file, const char **error_message,
}
if(!has_forced_leadout) {
- forced_leadout_track_num = is_cdda? 170 : cs->num_tracks;
+ forced_leadout_track_num = is_cdda? 170 : 255;
forced_leadout_track_offset = lead_out_offset;
}
if(!FLAC__metadata_object_cuesheet_insert_blank_track(cuesheet, cs->num_tracks)) {