I ran into a crash using TagLib with an m4a audio file.
<div><br></div><div>Here&#39;s the stack:</div><div><div><br></div><div>tagd.dll!std::_Debug_range&lt;std::_Vector_const_iterator&lt;char,std::allocator&lt;char&gt; &gt; &gt;(std::_Vector_const_iterator&lt;char,std::allocator&lt;char&gt; &gt; _First=0x61 &#39;a&#39;, std::_Vector_const_iterator&lt;char,std::allocator&lt;char&gt; &gt; _Last=0x00, const wchar_t * _File=0x635cbef8, unsigned int _Line=0x000003a5)  Line 1598 + 0x57 bytes<span class="Apple-tab-span" style="white-space:pre">        </span>C++</div>
<div>tagd.dll!std::vector&lt;char,std::allocator&lt;char&gt; &gt;::_Insert&lt;std::_Vector_const_iterator&lt;char,std::allocator&lt;char&gt; &gt; &gt;(std::_Vector_const_iterator&lt;char,std::allocator&lt;char&gt; &gt; _Where=..., std::_Vector_const_iterator&lt;char,std::allocator&lt;char&gt; &gt; _First=0x61 &#39;a&#39;, std::_Vector_const_iterator&lt;char,std::allocator&lt;char&gt; &gt; _Last=0x00, std::forward_iterator_tag __formal={...})  Line 933 + 0x45 bytes<span class="Apple-tab-span" style="white-space:pre">        </span>C++</div>
<div>tagd.dll!std::vector&lt;char,std::allocator&lt;char&gt; &gt;::insert&lt;std::_Vector_const_iterator&lt;char,std::allocator&lt;char&gt; &gt; &gt;(std::_Vector_const_iterator&lt;char,std::allocator&lt;char&gt; &gt; _Where=..., std::_Vector_const_iterator&lt;char,std::allocator&lt;char&gt; &gt; _First=0x61 &#39;a&#39;, std::_Vector_const_iterator&lt;char,std::allocator&lt;char&gt; &gt; _Last=0x00)  Line 890<span class="Apple-tab-span" style="white-space:pre">        </span>C++</div>
<div>tagd.dll!TagLib::ByteVector::mid(unsigned int index=0x00000010, unsigned int length=0xfffffff9)  Line 369 + 0xf9 bytes<span class="Apple-tab-span" style="white-space:pre">        </span>C++</div><div>tagd.dll!TagLib::MP4::Tag::parseData(TagLib::MP4::Atom * atom=0x0255f738, TagLib::File * file=0x03a9e84c, int expectedFlags=0xffffffff, bool freeForm=false)  Line 122 + 0x1d bytes<span class="Apple-tab-span" style="white-space:pre">        </span>C++</div>
<div>tagd.dll!TagLib::MP4::Tag::parseGnre(TagLib::MP4::Atom * atom=0x0255f738, TagLib::File * file=0x03a9e84c)  Line 143 + 0x18 bytes<span class="Apple-tab-span" style="white-space:pre">        </span>C++</div><div>tagd.dll!TagLib::MP4::Tag::Tag(TagLib::File * file=0x03a9e84c, TagLib::MP4::Atoms * atoms=0x0255a158)  Line 78 + 0x10 bytes<span class="Apple-tab-span" style="white-space:pre">        </span>C++</div>
<div>tagd.dll!TagLib::MP4::File::read(bool readProperties=true, TagLib::AudioProperties::ReadStyle audioPropertiesStyle=Fast)  Line 123 + 0x30 bytes<span class="Apple-tab-span" style="white-space:pre">        </span>C++</div><div>
tagd.dll!TagLib::MP4::File::File(TagLib::FileName file={...}, bool readProperties=true, TagLib::AudioProperties::ReadStyle audioPropertiesStyle=Fast)  Line 73<span class="Apple-tab-span" style="white-space:pre">        </span>C++</div>
</div><div><br></div><div>There&#39;s two problems:</div><div>- The obvious one is that ByteVector ByteVector::mid(uint index, uint length) const doesn&#39;t validate length, which can result in invalid iterators being passed into the STL insert function. I have attached a patch to check for that problem that seems to work fine. Can someone please verify and check it into the source tree?</div>
<div>- The root cause of this is why the value of length is bad in the first place. I don&#39;t see the calling code validating it anywhere, so I don&#39;t know if that&#39;s intentional. It might be that the audio file itself is corrupt but I&#39;m happy to provide it if anyone wants to look into this more.</div>
<div><br></div><div>Thanks,</div><div>Viraj</div>