[4/9] windowscodecs: GIF decoder should append a sub-block to current extension.
Dmitry Timoshkov
dmitry at baikal.ru
Mon Sep 17 22:59:11 CDT 2012
---
dlls/windowscodecs/ungif.c | 50 +++++++++++++++++++++++++++++++++++++++++-----
1 file 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;
}
--
1.7.11.6
More information about the wine-patches
mailing list