]> granicus.if.org Git - taglib/commitdiff
Fix crash when loading an empty mpeg file (#830)
authorXijian Yan <yanxijian@163.com>
Mon, 6 Nov 2017 15:48:17 +0000 (23:48 +0800)
committerStephen F. Booth <me@sbooth.org>
Mon, 6 Nov 2017 15:48:17 +0000 (09:48 -0600)
When loading an empty file (empty.txt -> empty.mp3 ), TagLib will crash.
buffer.size() is 0, then buffer.size() - 1 is undefined (unsigned int)

taglib/mpeg/mpegfile.cpp

index 217b03dd988ad08b129c248e27182733a22be3d9..517aea569ac8311cfad92770dbaa76bf3a93217a 100644 (file)
@@ -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);