]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/gifdecod.cpp
added wxAuiNotebook::Split() documentation
[wxWidgets.git] / src / common / gifdecod.cpp
index a96e64b18d6e1e1f7e7f181d0118239689486e6d..3ca73d91a6ce0df85062050b4f8714d7cc2e49df 100644 (file)
@@ -630,7 +630,7 @@ wxGIFErrorCode wxGIFDecoder::LoadGIF(wxInputStream& stream)
     m_szAnimation.SetWidth( buf[0] + 256 * buf[1] );
     m_szAnimation.SetHeight( buf[2] + 256 * buf[3] );
 
-    if ((m_szAnimation.GetWidth() == 0) || (m_szAnimation.GetHeight() == 0))
+    if (anim && ((m_szAnimation.GetWidth() == 0) || (m_szAnimation.GetHeight() == 0)))
     {
         return wxGIF_INVFORMAT;
     }
@@ -715,12 +715,12 @@ wxGIFErrorCode wxGIFDecoder::LoadGIF(wxInputStream& stream)
             {
                 while ((i = (unsigned char)stream.GetC()) != 0)
                 {
-                    stream.SeekI(i, wxFromCurrent);
-                    if (stream.Eof())
+                    if (stream.Eof() || (stream.LastRead() == 0))
                     {
                         done = true;
                         break;
                     }
+                    stream.SeekI(i, wxFromCurrent);
                 }
             }
         }
@@ -755,8 +755,8 @@ wxGIFErrorCode wxGIFDecoder::LoadGIF(wxInputStream& stream)
             pimg->w = buf[4] + 256 * buf[5];
             pimg->h = buf[6] + 256 * buf[7];
 
-            if ((pimg->w == 0) || (pimg->w > (unsigned int)m_szAnimation.GetWidth()) || 
-                (pimg->h == 0) || (pimg->h > (unsigned int)m_szAnimation.GetHeight()))
+            if (anim && ((pimg->w == 0) || (pimg->w > (unsigned int)m_szAnimation.GetWidth()) || 
+                        (pimg->h == 0) || (pimg->h > (unsigned int)m_szAnimation.GetHeight())))
             {
                 Destroy();
                 return wxGIF_INVFORMAT;
@@ -846,6 +846,11 @@ wxGIFErrorCode wxGIFDecoder::LoadGIF(wxInputStream& stream)
             /* skip all data */
             while ((i = (unsigned char)stream.GetC()) != 0)
             {
+                if (stream.Eof() || (stream.LastRead() == 0))
+                {
+                    Destroy();
+                    return wxGIF_INVFORMAT;
+                }
                 stream.SeekI(i, wxFromCurrent);
             }
         }
@@ -864,22 +869,26 @@ wxGIFErrorCode wxGIFDecoder::LoadGIF(wxInputStream& stream)
             if ((buf[8] & 0x80) == 0x80)
             {
                 unsigned int local_ncolors = 2 << (buf[8] & 0x07);
-                wxFileOffset pos = stream.TellI();
                 wxFileOffset numBytes = 3 * local_ncolors;
                 stream.SeekI(numBytes, wxFromCurrent);
-                if (stream.TellI() != (pos + numBytes))
-                {
-                    Destroy();
-                    return wxGIF_INVFORMAT;
-                }
             }
 
             /* initial code size */
             (void) stream.GetC();
+            if (stream.Eof() || (stream.LastRead() == 0))
+            {
+                Destroy();
+                return wxGIF_INVFORMAT;
+            }
 
             /* skip all data */
             while ((i = (unsigned char)stream.GetC()) != 0)
             {
+                if (stream.Eof() || (stream.LastRead() == 0))
+                {
+                    Destroy();
+                    return wxGIF_INVFORMAT;
+                }
                 stream.SeekI(i, wxFromCurrent);
             }
         }