summaryrefslogtreecommitdiff
path: root/thirdparty/libtiff/tif_lzw.c
diff options
context:
space:
mode:
authorAaron Boxer <boxerab@gmail.com>2014-12-09 14:33:38 -0500
committerAntonin Descampe <antonin@gmail.com>2015-07-03 19:19:17 +0200
commit6b0a8e3a0fc0dd18b01a8810b6867d6da8fa79e4 (patch)
tree4e34a268505357dad2498cf97580e72948cc4c1a /thirdparty/libtiff/tif_lzw.c
parenteadfad7a5014e0bf2a56667194af976fc9fc987c (diff)
upgraded to libtiff v4.0.4
Diffstat (limited to 'thirdparty/libtiff/tif_lzw.c')
-rw-r--r--thirdparty/libtiff/tif_lzw.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/thirdparty/libtiff/tif_lzw.c b/thirdparty/libtiff/tif_lzw.c
index fd9c7a0a..58345f0a 100644
--- a/thirdparty/libtiff/tif_lzw.c
+++ b/thirdparty/libtiff/tif_lzw.c
@@ -1,4 +1,4 @@
-/* $Id: tif_lzw.c,v 1.45 2011-04-02 20:54:09 bfriesen Exp $ */
+/* $Id: tif_lzw.c,v 1.47 2015-06-13 05:03:50 faxguy Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -268,6 +268,8 @@ LZWPreDecode(TIFF* tif, uint16 s)
if( sp->dec_codetab == NULL )
{
tif->tif_setupdecode( tif );
+ if( sp->dec_codetab == NULL )
+ return (0);
}
/*
@@ -434,16 +436,18 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
if (code == CODE_EOI)
break;
if (code == CODE_CLEAR) {
- free_entp = sp->dec_codetab + CODE_FIRST;
- _TIFFmemset(free_entp, 0,
- (CSIZE - CODE_FIRST) * sizeof (code_t));
- nbits = BITS_MIN;
- nbitsmask = MAXCODE(BITS_MIN);
- maxcodep = sp->dec_codetab + nbitsmask-1;
- NextCode(tif, sp, bp, code, GetNextCode);
+ do {
+ free_entp = sp->dec_codetab + CODE_FIRST;
+ _TIFFmemset(free_entp, 0,
+ (CSIZE - CODE_FIRST) * sizeof (code_t));
+ nbits = BITS_MIN;
+ nbitsmask = MAXCODE(BITS_MIN);
+ maxcodep = sp->dec_codetab + nbitsmask-1;
+ NextCode(tif, sp, bp, code, GetNextCode);
+ } while (code == CODE_CLEAR); /* consecutive CODE_CLEAR codes */
if (code == CODE_EOI)
break;
- if (code >= CODE_CLEAR) {
+ if (code > CODE_CLEAR) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"LZWDecode: Corrupted LZW table at scanline %d",
tif->tif_row);
@@ -653,16 +657,18 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
if (code == CODE_EOI)
break;
if (code == CODE_CLEAR) {
- free_entp = sp->dec_codetab + CODE_FIRST;
- _TIFFmemset(free_entp, 0,
- (CSIZE - CODE_FIRST) * sizeof (code_t));
- nbits = BITS_MIN;
- nbitsmask = MAXCODE(BITS_MIN);
- maxcodep = sp->dec_codetab + nbitsmask;
- NextCode(tif, sp, bp, code, GetNextCodeCompat);
+ do {
+ free_entp = sp->dec_codetab + CODE_FIRST;
+ _TIFFmemset(free_entp, 0,
+ (CSIZE - CODE_FIRST) * sizeof (code_t));
+ nbits = BITS_MIN;
+ nbitsmask = MAXCODE(BITS_MIN);
+ maxcodep = sp->dec_codetab + nbitsmask;
+ NextCode(tif, sp, bp, code, GetNextCodeCompat);
+ } while (code == CODE_CLEAR); /* consecutive CODE_CLEAR codes */
if (code == CODE_EOI)
break;
- if (code >= CODE_CLEAR) {
+ if (code > CODE_CLEAR) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"LZWDecode: Corrupted LZW table at scanline %d",
tif->tif_row);