-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 27.10.2011 10:23, Georg Gottleuber wrote: >>> - if (st->buffer.maxval - st->early_change == >>> st->dict.size) + if (st->buffer.maxval - >>> st->early_change + 2 == st->dict.size) { if >>> (!lzw_buffer_inc_bitsize (&st->buffer)) { > > I found a very good explanation for a "+1" at this place (a second > +1 is of course still missing).
I have found the second +1 It is caused by mixing st->dict.size with table entry content: ISO-32000 says: "The first output code that is 10 bits long shall be the one following the creation of table entry 511" (entry 511, not dict.size = 511) If we create table entry in function lzw_dict_add with: d->table[d->size++] = *s; dict.size is already 511 after the entry of 510. So we have test against st->dict.size-1 (or add 1 to maxval) Regards, Georg -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk7T/qYACgkQ5sLITM1qIaIh8QCeJuWyXnCVvrIubaDU6c10Bdh3 V34AnA/sQ5bRH/0/mx0Xt2AlWz+HKwEU =tzSA -----END PGP SIGNATURE-----