diff --git a/ape/apeitem.cpp b/ape/apeitem.cpp index d4cca52d..6f5fc907 100644 --- a/ape/apeitem.cpp +++ b/ape/apeitem.cpp @@ -123,8 +123,13 @@ bool APE::Item::isEmpty() const } } -void APE::Item::parse(const ByteVector& data) +void APE::Item::parse(const ByteVector &data) { + if(data.size() < 10) { + debug("APE::Item::parse() -- no data in item"); + return; + } + uint valueLength = data.mid(0, 4).toUInt(false); uint flags = data.mid(4, 4).toUInt(false); diff --git a/toolkit/tbytevector.cpp b/toolkit/tbytevector.cpp index 78c1ac23..8bd90615 100644 --- a/toolkit/tbytevector.cpp +++ b/toolkit/tbytevector.cpp @@ -189,6 +189,12 @@ namespace TagLib { T toNumber(const std::vector &data, bool mostSignificantByteFirst) { T sum = 0; + + if(data.size() <= 0) { + debug("ByteVectorMirror::toNumber() -- data is empty, returning 0"); + return sum; + } + uint size = sizeof(T); uint last = data.size() > size ? size - 1 : data.size() - 1;