]> granicus.if.org Git - taglib/commitdiff
Make sure that there's (a) data in a bytevector that we're trying to convert
authorScott Wheeler <wheeler@kde.org>
Thu, 28 Oct 2004 22:11:41 +0000 (22:11 +0000)
committerScott Wheeler <wheeler@kde.org>
Thu, 28 Oct 2004 22:11:41 +0000 (22:11 +0000)
to an integer before trying to convert it and (b) make sure that there's data
in an APE::Item before trying to parse it.

BUG:92028

git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@358637 283d02a7-25f6-0310-bc7c-ecb5cbfe19da

ape/apeitem.cpp
toolkit/tbytevector.cpp

index d4cca52d436c828cb686fb2b8843558c6a37ac04..6f5fc9075e3fcb563ca7adcc2c988e07480ee7a3 100644 (file)
@@ -123,8 +123,13 @@ bool APE::Item::isEmpty() const
   }
 }
 
-void APE::Item::parse(const ByteVectordata)
+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);
 
index 78c1ac23cdda62c22c038949e9674633c6354316..8bd90615f79e714759cd5ce14210379a63535eca 100644 (file)
@@ -189,6 +189,12 @@ namespace TagLib {
   T toNumber(const std::vector<char> &data, bool mostSignificantByteFirst)
   {
     T sum = 0;
+
+    if(data.size() <= 0) {
+      debug("ByteVectorMirror::toNumber<T>() -- data is empty, returning 0");
+      return sum;
+    }
+
     uint size = sizeof(T);
     uint last = data.size() > size ? size - 1 : data.size() - 1;