diff --git a/src/common/anidecod.cpp b/src/common/anidecod.cpp index 61888984a6..0fed465c01 100644 --- a/src/common/anidecod.cpp +++ b/src/common/anidecod.cpp @@ -331,6 +331,11 @@ bool wxANIDecoder::Load( wxInputStream& stream ) if (m_nFrames==0) return false; + // Without any loaded icon, m_images[0] below and the public accessors + // would index into an empty vector. + if (m_images.empty()) + return false; + if (m_nFrames==m_images.size()) { // if no SEQ chunk is available, display the frames in the order @@ -340,6 +345,15 @@ bool wxANIDecoder::Load( wxInputStream& stream ) m_info[i].m_imageIndex = i; } + // SEQ chunk indices come straight from the input, so reject the file if + // any of them would index m_images out of range. + for (unsigned int i=0; i(m_info[i].m_imageIndex) >= m_images.size()) + return false; + } + // if some frame has an invalid delay, use the global delay given in the // ANI header for (unsigned int i=0; i