aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXijian Yan <yanxijian@163.com>2017-11-06 23:48:17 +0800
committerStephen F. Booth <me@sbooth.org>2017-11-06 09:48:17 -0600
commit249f892455d2759d45a6f5976f03924c04910411 (patch)
tree3f265a484e163454857c3151d55295cd64be898b
parentcb9f07d9dcd791b63e622da43f7b232adaec0a9a (diff)
Fix crash when loading an empty mpeg file (#830)
When loading an empty file (empty.txt -> empty.mp3 ), TagLib will crash. buffer.size() is 0, then buffer.size() - 1 is undefined (unsigned int)
-rw-r--r--taglib/mpeg/mpegfile.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/taglib/mpeg/mpegfile.cpp b/taglib/mpeg/mpegfile.cpp
index 217b03dd..517aea56 100644
--- a/taglib/mpeg/mpegfile.cpp
+++ b/taglib/mpeg/mpegfile.cpp
@@ -108,6 +108,9 @@ bool MPEG::File::isSupported(IOStream *stream)
long headerOffset;
const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true, &headerOffset);
+ if(buffer.isEmpty())
+ return false;
+
const long originalPosition = stream->tell();
AdapterFile file(stream);