From cfb6f46473777e444c8124318aa78d33aae64459 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 20 Mar 2017 15:46:06 -0700 Subject: Upgrade libtiff to 4.0.7. Change-Id: If3f67767f738b7f23230ca8c37c9af2e31696e82 Reviewed-on: https://pdfium-review.googlesource.com/3117 Commit-Queue: dsinclair Reviewed-by: dsinclair --- third_party/libtiff/tif_lzw.c | 56 +++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 23 deletions(-) (limited to 'third_party/libtiff/tif_lzw.c') diff --git a/third_party/libtiff/tif_lzw.c b/third_party/libtiff/tif_lzw.c index 9b76dd03b3..240e19c2e0 100644 --- a/third_party/libtiff/tif_lzw.c +++ b/third_party/libtiff/tif_lzw.c @@ -1,4 +1,4 @@ -/* $Id: tif_lzw.c,v 1.49 2015-08-30 21:07:44 erouault Exp $ */ +/* $Id: tif_lzw.c,v 1.52 2016-09-04 21:32:56 erouault Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -240,8 +240,8 @@ LZWSetupDecode(TIFF* tif) */ code = 255; do { - sp->dec_codetab[code].value = code; - sp->dec_codetab[code].firstchar = code; + sp->dec_codetab[code].value = (unsigned char)code; + sp->dec_codetab[code].firstchar = (unsigned char)code; sp->dec_codetab[code].length = 1; sp->dec_codetab[code].next = NULL; } while (code--); @@ -411,14 +411,15 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) /* * Residue satisfies only part of the decode request. */ - op += residue, occ -= residue; + op += residue; + occ -= residue; tp = op; do { int t; --tp; t = codep->value; codep = codep->next; - *tp = t; + *tp = (char)t; } while (--residue && codep); sp->dec_restart = 0; } @@ -454,7 +455,8 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) tif->tif_row); return (0); } - *op++ = (char)code, occ--; + *op++ = (char)code; + occ--; oldcodep = sp->dec_codetab + code; continue; } @@ -532,16 +534,19 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) --tp; t = codep->value; codep = codep->next; - *tp = t; + *tp = (char)t; } while (codep && tp > op); if (codep) { codeLoop(tif, module); break; } assert(occ >= len); - op += len, occ -= len; - } else - *op++ = (char)code, occ--; + op += len; + occ -= len; + } else { + *op++ = (char)code; + occ--; + } } tif->tif_rawcp = (uint8*) bp; @@ -635,7 +640,8 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) /* * Residue satisfies only part of the decode request. */ - op += residue, occ -= residue; + op += residue; + occ -= residue; tp = op; do { *--tp = codep->value; @@ -675,7 +681,8 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) tif->tif_row); return (0); } - *op++ = code, occ--; + *op++ = (char)code; + occ--; oldcodep = sp->dec_codetab + code; continue; } @@ -741,17 +748,20 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) break; } assert(occ >= codep->length); - op += codep->length, occ -= codep->length; + op += codep->length; + occ -= codep->length; tp = op; do { *--tp = codep->value; } while( (codep = codep->next) != NULL ); - } else - *op++ = code, occ--; + } else { + *op++ = (char)code; + occ--; + } } tif->tif_rawcp = (uint8*) bp; - sp->lzw_nbits = nbits; + sp->lzw_nbits = (unsigned short)nbits; sp->lzw_nextdata = nextdata; sp->lzw_nextbits = nextbits; sp->dec_nbitsmask = nbitsmask; @@ -900,7 +910,7 @@ LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) nbits = sp->lzw_nbits; op = tif->tif_rawcp; limit = sp->enc_rawlimit; - ent = sp->enc_oldcode; + ent = (hcode_t)sp->enc_oldcode; if (ent == (hcode_t) -1 && cc > 0) { /* @@ -936,7 +946,7 @@ LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) disp = 1; do { /* - * Avoid pointer arithmetic 'cuz of + * Avoid pointer arithmetic because of * wraparound problems with segments. */ if ((h -= disp) < 0) @@ -963,8 +973,8 @@ LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) op = tif->tif_rawdata; } PutNextCode(op, ent); - ent = c; - hp->code = free_ent++; + ent = (hcode_t)c; + hp->code = (hcode_t)(free_ent++); hp->hash = fcode; if (free_ent == CODE_MAX-1) { /* table is full, emit clear code and reset */ @@ -1021,9 +1031,9 @@ LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) sp->enc_oldcode = ent; sp->lzw_nextdata = nextdata; sp->lzw_nextbits = nextbits; - sp->lzw_free_ent = free_ent; - sp->lzw_maxcode = maxcode; - sp->lzw_nbits = nbits; + sp->lzw_free_ent = (unsigned short)free_ent; + sp->lzw_maxcode = (unsigned short)maxcode; + sp->lzw_nbits = (unsigned short)nbits; tif->tif_rawcp = op; return (1); } -- cgit v1.2.3