From 98f6b268a556ac27eb0cd6d629b0ee95721f766b Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 9 May 2021 12:15:00 +0200 Subject: [PATCH] Fix reading empty ID3v1 fields --- id3/id3v1tag.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/id3/id3v1tag.cpp b/id3/id3v1tag.cpp index 6344038..74233ab 100644 --- a/id3/id3v1tag.cpp +++ b/id3/id3v1tag.cpp @@ -283,10 +283,13 @@ void Id3v1Tag::ensureTextValuesAreProperlyEncoded() void Id3v1Tag::readValue(TagValue &value, size_t maxLength, const char *buffer) { const char *end = buffer + maxLength - 1; - while ((*end == 0x0 || *end == ' ') && end > buffer) { + while ((*end == 0x0 || *end == ' ') && end >= buffer) { --end; --maxLength; } + if (buffer == end) { + return; + } if (maxLength >= 3 && BE::toUInt24(buffer) == 0x00EFBBBF) { value.assignData(buffer + 3, maxLength - 3, TagDataType::Text, TagTextEncoding::Utf8); } else {