From: Xijian Yan Date: Mon, 6 Nov 2017 15:48:17 +0000 (+0800) Subject: Fix crash when loading an empty mpeg file (#830) X-Git-Tag: v1.12-beta-1~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=249f892455d2759d45a6f5976f03924c04910411;p=taglib 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) --- 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);