diff options
Diffstat (limited to 'third_party/libtiff/tif_packbits.c')
-rw-r--r-- | third_party/libtiff/tif_packbits.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/third_party/libtiff/tif_packbits.c b/third_party/libtiff/tif_packbits.c index 9e77190131..d2a0165de9 100644 --- a/third_party/libtiff/tif_packbits.c +++ b/third_party/libtiff/tif_packbits.c @@ -1,4 +1,4 @@ -/* $Id: tif_packbits.c,v 1.22 2012-06-20 05:25:33 fwarmerdam Exp $ */ +/* $Id: tif_packbits.c,v 1.24 2016-09-04 21:32:56 erouault Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -38,7 +38,8 @@ PackBitsPreEncode(TIFF* tif, uint16 s) { (void) s; - if (!(tif->tif_data = (uint8*)_TIFFmalloc(sizeof(tmsize_t)))) + tif->tif_data = (uint8*)_TIFFmalloc(sizeof(tmsize_t)); + if (tif->tif_data == NULL) return (0); /* * Calculate the scanline/tile-width size in bytes. @@ -81,7 +82,9 @@ PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) /* * Find the longest string of identical bytes. */ - b = *bp++, cc--, n = 1; + b = *bp++; + cc--; + n = 1; for (; cc > 0 && b == *bp; cc--, bp++) n++; again: @@ -222,7 +225,8 @@ PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) bp = (char*) tif->tif_rawcp; cc = tif->tif_rawcc; while (cc > 0 && occ > 0) { - n = (long) *bp++, cc--; + n = (long) *bp++; + cc--; /* * Watch out for compilers that * don't sign extend chars... @@ -241,7 +245,8 @@ PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) n = (long)occ; } occ -= n; - b = *bp++, cc--; + b = *bp++; + cc--; while (n-- > 0) *op++ = (uint8) b; } else { /* copy next n+1 bytes literally */ |