X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/664e13143ee51a6b1aa1c30d1401ac04b11bdcca..f7008bad873d18e389109f1e2c3af51323d16556:/src/common/gifdecod.cpp?ds=sidebyside diff --git a/src/common/gifdecod.cpp b/src/common/gifdecod.cpp index fb55baac1b..76450239a3 100644 --- a/src/common/gifdecod.cpp +++ b/src/common/gifdecod.cpp @@ -19,6 +19,8 @@ #ifndef WX_PRECOMP #include "wx/palette.h" + #include "wx/intl.h" + #include "wx/log.h" #endif #include @@ -51,7 +53,7 @@ public: unsigned char *pal; // palette unsigned int ncolours; // number of colours - DECLARE_NO_COPY_CLASS(GIFImage) + wxDECLARE_NO_COPY_CLASS(GIFImage); }; wxDECLARE_SCOPED_PTR(GIFImage, GIFImagePtr) @@ -757,9 +759,30 @@ wxGIFErrorCode wxGIFDecoder::LoadGIF(wxInputStream& stream) pimg->w = buf[4] + 256 * buf[5]; pimg->h = buf[6] + 256 * buf[7]; - if ( anim && ((pimg->w == 0) || (pimg->w > (unsigned int)m_szAnimation.GetWidth()) || - (pimg->h == 0) || (pimg->h > (unsigned int)m_szAnimation.GetHeight())) ) - return wxGIF_INVFORMAT; + if ( anim ) + { + // some GIF images specify incorrect animation size but we can + // still open them if we fix up the animation size, see #9465 + if ( m_nFrames == 0 ) + { + if ( pimg->w > (unsigned)m_szAnimation.x ) + m_szAnimation.x = pimg->w; + if ( pimg->h > (unsigned)m_szAnimation.y ) + m_szAnimation.y = pimg->h; + } + else // subsequent frames + { + // check that we have valid size + if ( (!pimg->w || pimg->w > (unsigned)m_szAnimation.x) || + (!pimg->h || pimg->h > (unsigned)m_szAnimation.y) ) + { + wxLogError(_("Incorrect GIF frame size (%u, %d) for " + "the frame #%u"), + pimg->w, pimg->h, m_nFrames); + return wxGIF_INVFORMAT; + } + } + } interl = ((buf[8] & 0x40)? 1 : 0); size = pimg->w * pimg->h;