Dmitry Timoshkov : windowscodecs: GIF decoder should append a sub-block to current extension.

Alexandre Julliard julliard at winehq.org
Tue Sep 18 14:04:29 CDT 2012


Module: wine
Branch: master
Commit: aaa682950d4fa818dc08810de927f18dfcab8767
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=aaa682950d4fa818dc08810de927f18dfcab8767

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Tue Sep 18 12:59:11 2012 +0900

windowscodecs: GIF decoder should append a sub-block to current extension.

---

 dlls/windowscodecs/ungif.c |   50 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/dlls/windowscodecs/ungif.c b/dlls/windowscodecs/ungif.c
index 7984e3a..2330192 100644
--- a/dlls/windowscodecs/ungif.c
+++ b/dlls/windowscodecs/ungif.c
@@ -222,6 +222,32 @@ AddExtensionBlock(Extensions *New,
     return (GIF_OK);
 }
 
+static int
+AppendExtensionBlock(Extensions *New,
+                     int Len,
+                     const unsigned char ExtData[])
+{
+    ExtensionBlock *ep;
+
+    if (New->ExtensionBlocks == NULL)
+        return (GIF_ERROR);
+
+    ep = &New->ExtensionBlocks[New->ExtensionBlockCount - 1];
+
+    ep->Bytes = ungif_realloc(ep->Bytes, ep->ByteCount + Len + 1);
+    if (ep->Bytes == NULL)
+        return (GIF_ERROR);
+
+    if (ExtData)
+    {
+        ep->Bytes[ep->ByteCount] = Len;
+        memcpy(ep->Bytes + ep->ByteCount + 1, ExtData, Len);
+        ep->ByteCount += Len + 1;
+    }
+
+    return (GIF_OK);
+}
+
 static void
 FreeExtension(Extensions *Extensions)
 {
@@ -898,16 +924,30 @@ DGifSlurp(GifFileType * GifFile) {
 
               Extensions->Function = Function;
 
+              /* Create an extension block with our data */
+              if (AddExtensionBlock(Extensions, ExtData[0], &ExtData[1]) == GIF_ERROR)
+                  return (GIF_ERROR);
+
               while (ExtData != NULL) {
+                  int Len;
+                  GifByteType *Data;
 
-                  /* Create an extension block with our data */
-                  if (AddExtensionBlock(Extensions, ExtData[0], &ExtData[1])
-                      == GIF_ERROR)
+                  if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR)
                       return (GIF_ERROR);
 
-                  if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR)
+                  if (ExtData)
+                  {
+                      Len = ExtData[0];
+                      Data = &ExtData[1];
+                  }
+                  else
+                  {
+                      Len = 0;
+                      Data = NULL;
+                  }
+
+                  if (AppendExtensionBlock(Extensions, Len, Data) == GIF_ERROR)
                       return (GIF_ERROR);
-                  temp_save.Function = 0;
               }
               break;
           }




More information about the wine-cvs mailing list