summaryrefslogtreecommitdiffstats
path: root/src/library
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2021-01-24 20:17:02 +0100
committerUwe Klotz <uklotz@mixxx.org>2021-01-24 20:21:23 +0100
commit973b001a259c71a5882d3cac3c78bdf06bd2a86c (patch)
tree850aba07b8f01e37f7668923ecf3353d078ef8b0 /src/library
parent82fd196e7c9b33eff79cdbc9f052407d28e2df75 (diff)
Prevent invalid cover art hash values
Diffstat (limited to 'src/library')
-rw-r--r--src/library/coverart.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/library/coverart.cpp b/src/library/coverart.cpp
index db06332155..dcaf17a9da 100644
--- a/src/library/coverart.cpp
+++ b/src/library/coverart.cpp
@@ -51,14 +51,22 @@ QString coverInfoToString(const CoverInfo& info) {
//static
quint16 CoverImageUtils::calculateHash(
const QImage& image) {
- const auto hash = qChecksum(
+ auto hash = qChecksum(
reinterpret_cast<const char*>(image.constBits()),
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
image.sizeInBytes()
#else
image.byteCount()
#endif
- );
+ );
+ // In rare cases the calculated checksum could be equal to the
+ // reserved value defaultHash() which might cause unexpected
+ // behavior. In this case we simply invert all bits to get a hash
+ // value that is considered valid.
+ // https://mixxx.discourse.group/t/mixxx-2-2-4-reads-id3v1-tags-mixxx-2-3-or-2-4-does-not/21041/11
+ if (hash == defaultHash() && !image.isNull()) {
+ hash = ~hash;
+ }
DEBUG_ASSERT(image.isNull() || isValidHash(hash));
DEBUG_ASSERT(!image.isNull() || hash == defaultHash());
return hash;