summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2018-07-28 11:58:59 (GMT)
committerfvogel <fvogelnew1@free.fr>2018-07-28 11:58:59 (GMT)
commit93d974c265533cf2445446954346be8192e850a0 (patch)
tree86e2aefd9618b66b586d33732fb31edbf1f007df /generic
parentb2326c6455cbaac9f136f504622c5a35fa9dbb44 (diff)
downloadtk-93d974c265533cf2445446954346be8192e850a0.zip
tk-93d974c265533cf2445446954346be8192e850a0.tar.gz
tk-93d974c265533cf2445446954346be8192e850a0.tar.bz2
Fix [fbaed1f66b]: [image create photo] errors out on a sane animated gif. Cherrypicked [95f4a8e283]
Diffstat (limited to 'generic')
-rw-r--r--generic/tkImgGIF.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c
index 409300c..e7f4582 100644
--- a/generic/tkImgGIF.c
+++ b/generic/tkImgGIF.c
@@ -963,9 +963,9 @@ ReadImage(
* Last pass reset the decoder, so the first code we see
* must be a singleton. Seed the stack with it, and set up
* the old/first code pointers for insertion into the
- * string table. We can't just roll this into the
- * clearCode test above, because at that point we have not
- * yet read the next code.
+ * codes table. We can't just roll this into the clearCode
+ * test above, because at that point we have not yet read
+ * the next code.
*/
*top++ = append[code];
@@ -976,11 +976,11 @@ ReadImage(
inCode = code;
- if (code == maxCode) {
+ if ((code == maxCode) && (maxCode < (1 << MAX_LWZ_BITS))) {
/*
* maxCode is always one bigger than our highest assigned
* code. If the code we see is equal to maxCode, then we
- * are about to add a new string to the table. ???
+ * are about to add a new entry to the codes table.
*/
*top++ = firstCode;
@@ -989,7 +989,7 @@ ReadImage(
while (code > clearCode) {
/*
- * Populate the stack by tracing the string in the string
+ * Populate the stack by tracing the code in the codes
* table from its tail to its head
*/
@@ -998,28 +998,24 @@ ReadImage(
}
firstCode = append[code];
- /*
- * If there's no more room in our string table, quit.
- * Otherwise, add a new string to the table
- */
-
- if (maxCode >= (1 << MAX_LWZ_BITS)) {
- return TCL_OK;
- }
-
- /*
- * Push the head of the string onto the stack.
- */
+ /*
+ * Push the head of the code onto the stack.
+ */
- *top++ = firstCode;
+ *top++ = firstCode;
- /*
- * Add a new string to the string table
- */
+ if (maxCode < (1 << MAX_LWZ_BITS)) {
+ /*
+ * If there's still room in our codes table, add a new entry.
+ * Otherwise don't, and keep using the current table.
+ * See DEFERRED CLEAR CODE IN LZW COMPRESSION in the GIF89a
+ * specification.
+ */
- prefix[maxCode] = oldCode;
- append[maxCode] = firstCode;
- maxCode++;
+ prefix[maxCode] = oldCode;
+ append[maxCode] = firstCode;
+ maxCode++;
+ }
/*
* maxCode tells us the maximum code value we can accept. If