tools/gif2tiff.c:518: error: Buffer Overrun L3
  Offset: [7, +oo] (⇐ [0, +oo] + 7) Size: [0, +oo] by call to `TIFFClose`.

tools/gif2tiff.c:514:6: Call
512. 	    stripsize = TIFFVStripSize(tif, rowsperstrip);
513. 	}
514. 	if (TIFFWriteEncodedStrip(tif, strip, newras+row*width, stripsize) < 0)
          ^
515. 	    break;
516. 	strip++;

libtiff/tif_write.c:183:1: Parameter `*tif->tif_rawdata`
  181.  * NB: Image length must be setup before writing.
  182.  */
  183. tmsize_t
       ^
  184. TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc)
  185. {

tools/gif2tiff.c:518:5: Call
516. 	strip++;
517.     }
518.     TIFFClose(tif);
         ^
519. 
520.     _TIFFfree(newras);

libtiff/tif_close.c:122:1: Parameter `*tif->tif_rawdata`
  120.  */
  121. 
  122. void
       ^
  123. TIFFClose(TIFF* tif)
  124. {

libtiff/tif_close.c:128:2: Call
  126. 	thandle_t fd = tif->tif_clientdata;
  127. 
  128. 	TIFFCleanup(tif);
        ^
  129. 	(void) (*closeproc)(fd);
  130. }

libtiff/tif_close.c:46:1: Parameter `*tif->tif_rawdata`
    44.  */
    45. 
    46. void
        ^
    47. TIFFCleanup(TIFF* tif)
    48. {

libtiff/tif_close.c:53:3: Call
    51.          */
    52. 	if (tif->tif_mode != O_RDONLY)
    53. 		TIFFFlush(tif);
          ^
    54. 	(*tif->tif_cleanup)(tif);
    55. 	TIFFFreeDirectory(tif);

libtiff/tif_flush.c:32:1: Parameter `*tif->tif_rawdata`
      30. #include "tiffiop.h"
      31. 
      32. int
          ^
      33. TIFFFlush(TIFF* tif)
      34. {

libtiff/tif_flush.c:38:10: Call
      36.         return 1;
      37. 
      38.     if (!TIFFFlushData(tif))
                   ^
      39.         return (0);
      40.                 

libtiff/tif_flush.c:98:1: Parameter `*tif->tif_rawdata`
         96.  * problems for other people. 
         97.  */
         98. int
             ^
         99. TIFFFlushData(TIFF* tif)
        100. {

libtiff/tif_flush.c:108:10: Call
        106. 			return (0);
        107. 	}
        108. 	return (TIFFFlushData1(tif));
                      ^
        109. }
        110. 

libtiff/tif_write.c:712:1: Parameter `*tif->tif_rawdata`
          710.  * for infinite recursion.
          711.  */
          712. int
               ^
          713. TIFFFlushData1(TIFF* tif)
          714. {

libtiff/tif_write.c:718:4: Call
          716. 		if (!isFillOrder(tif, tif->tif_dir.td_fillorder) &&
          717. 		    (tif->tif_flags & TIFF_NOBITREV) == 0)
          718. 			TIFFReverseBits((uint8*)tif->tif_rawdata,
                  ^
          719. 			    tif->tif_rawcc);
          720. 		if (!TIFFAppendToStrip(tif,

libtiff/tif_swab.c:285:1: <Length trace>
283. }
284. 
285. void
     ^
286. TIFFReverseBits(uint8* cp, tmsize_t n)  
287. {

libtiff/tif_swab.c:285:1: Parameter `*cp`
            283. }
            284. 
            285. void
                 ^
            286. TIFFReverseBits(uint8* cp, tmsize_t n)  
            287. {

libtiff/tif_swab.c:296:3: Array access: Offset: [7, +oo] (⇐ [0, +oo] + 7) Size: [0, +oo] by call to `TIFFClose` 
            294. 		cp[5] = TIFFBitRevTable[cp[5]];
            295. 		cp[6] = TIFFBitRevTable[cp[6]];
            296. 		cp[7] = TIFFBitRevTable[cp[7]];
                   ^
            297. 		cp += 8;
            298. 	}

void
TIFFReverseBits(uint8* cp, tmsize_t n)
{
	for (; n > 8; n -= 8) {
		cp[0] = TIFFBitRevTable[cp[0]];
		cp[1] = TIFFBitRevTable[cp[1]];
		cp[2] = TIFFBitRevTable[cp[2]];
		cp[3] = TIFFBitRevTable[cp[3]];
		cp[4] = TIFFBitRevTable[cp[4]];
		cp[5] = TIFFBitRevTable[cp[5]];
		cp[6] = TIFFBitRevTable[cp[6]];
		cp[7] = TIFFBitRevTable[cp[7]];
		cp += 8;
	}
	while (n-- > 0)
		*cp = TIFFBitRevTable[*cp], cp++;
}
['void\nrasterize(int interleaved, char* mode)\n{\n    register unsigned long row;\n    unsigned char *newras;\n    unsigned char *ras;\n    TIFF *tif;\n    tstrip_t strip;\n    tsize_t stripsize;\n    if ((newras = (unsigned char*) _TIFFmalloc(width*height+EXTRAFUDGE)) == NULL) {\n        fprintf(stderr, "not enough memory for image\\n");\n        return;\n    }\n#define DRAWSEGMENT(offset, step) {\t\t\t\\\n        for (row = offset; row < height; row += step) {\t\\\n            _TIFFmemcpy(newras + row*width, ras, width);\\\n            ras += width;                            \t\\\n        }\t\t\t\t\t\t\\\n    }\n    ras = raster;\n    if (interleaved) {\n        DRAWSEGMENT(0, 8);\n        DRAWSEGMENT(4, 8);\n        DRAWSEGMENT(2, 4);\n        DRAWSEGMENT(1, 2);\n    } else\n        DRAWSEGMENT(0, 1);\n#undef DRAWSEGMENT\n    tif = TIFFOpen(imagename, mode);\n    if (!tif) {\n\tTIFFError(imagename,"Can not open output image");\n\texit(-1);\n    }\n    TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32) width);\n    TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32) height);\n    TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE);\n    TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);\n    TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);\n    TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);\n    TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,\n\trowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip));\n    TIFFSetField(tif, TIFFTAG_COMPRESSION, compression);\n    switch (compression) {\n    case COMPRESSION_LZW:\n    case COMPRESSION_DEFLATE:\n\t    if (predictor != 0)\n\t\t    TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor);\n\t    break;\n    }\n    TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue);\n    TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);\n    strip = 0;\n    stripsize = TIFFStripSize(tif);\n    for (row=0; row<height; row += rowsperstrip) {\n\tif (rowsperstrip > height-row) {\n\t    rowsperstrip = height-row;\n\t    stripsize = TIFFVStripSize(tif, rowsperstrip);\n\t}\n\tif (TIFFWriteEncodedStrip(tif, strip, newras+row*width, stripsize) < 0)\n\t    break;\n\tstrip++;\n    }\n    TIFFClose(tif);\n    _TIFFfree(newras);\n}', 'tmsize_t\nTIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc)\n{\n\tstatic const char module[] = "TIFFWriteEncodedStrip";\n\tTIFFDirectory *td = &tif->tif_dir;\n\tuint16 sample;\n\tif (!WRITECHECKSTRIPS(tif, module))\n\t\treturn ((tmsize_t) -1);\n\tif (strip >= td->td_nstrips) {\n\t\tif (td->td_planarconfig == PLANARCONFIG_SEPARATE) {\n\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t    "Can not grow image by strips when using separate planes");\n\t\t\treturn ((tmsize_t) -1);\n\t\t}\n\t\tif (!TIFFGrowStrips(tif, 1, module))\n\t\t\treturn ((tmsize_t) -1);\n\t\ttd->td_stripsperimage =\n\t\t    TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip);\n\t}\n\tif (!BUFFERCHECK(tif))\n\t\treturn ((tmsize_t) -1);\n        tif->tif_flags |= TIFF_BUF4WRITE;\n\ttif->tif_curstrip = strip;\n\ttif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;\n\tif ((tif->tif_flags & TIFF_CODERSETUP) == 0) {\n\t\tif (!(*tif->tif_setupencode)(tif))\n\t\t\treturn ((tmsize_t) -1);\n\t\ttif->tif_flags |= TIFF_CODERSETUP;\n\t}\n\ttif->tif_rawcc = 0;\n\ttif->tif_rawcp = tif->tif_rawdata;\n\tif( td->td_stripbytecount[strip] > 0 )\n        {\n            tif->tif_curoff = 0;\n        }\n\ttif->tif_flags &= ~TIFF_POSTENCODE;\n\tsample = (uint16)(strip / td->td_stripsperimage);\n\tif (!(*tif->tif_preencode)(tif, sample))\n\t\treturn ((tmsize_t) -1);\n\ttif->tif_postdecode( tif, (uint8*) data, cc );\n\tif (!(*tif->tif_encodestrip)(tif, (uint8*) data, cc, sample))\n\t\treturn (0);\n\tif (!(*tif->tif_postencode)(tif))\n\t\treturn ((tmsize_t) -1);\n\tif (!isFillOrder(tif, td->td_fillorder) &&\n\t    (tif->tif_flags & TIFF_NOBITREV) == 0)\n\t\tTIFFReverseBits(tif->tif_rawdata, tif->tif_rawcc);\n\tif (tif->tif_rawcc > 0 &&\n\t    !TIFFAppendToStrip(tif, strip, tif->tif_rawdata, tif->tif_rawcc))\n\t\treturn ((tmsize_t) -1);\n\ttif->tif_rawcc = 0;\n\ttif->tif_rawcp = tif->tif_rawdata;\n\treturn (cc);\n}', 'void\nTIFFClose(TIFF* tif)\n{\n\tTIFFCloseProc closeproc = tif->tif_closeproc;\n\tthandle_t fd = tif->tif_clientdata;\n\tTIFFCleanup(tif);\n\t(void) (*closeproc)(fd);\n}', 'void\nTIFFCleanup(TIFF* tif)\n{\n\tif (tif->tif_mode != O_RDONLY)\n\t\tTIFFFlush(tif);\n\t(*tif->tif_cleanup)(tif);\n\tTIFFFreeDirectory(tif);\n\tif (tif->tif_dirlist)\n\t\t_TIFFfree(tif->tif_dirlist);\n\twhile( tif->tif_clientinfo )\n\t{\n\t\tTIFFClientInfoLink *link = tif->tif_clientinfo;\n\t\ttif->tif_clientinfo = link->next;\n\t\t_TIFFfree( link->name );\n\t\t_TIFFfree( link );\n\t}\n\tif (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER))\n\t\t_TIFFfree(tif->tif_rawdata);\n\tif (isMapped(tif))\n\t\tTIFFUnmapFileContents(tif, tif->tif_base, (toff_t)tif->tif_size);\n\tif (tif->tif_fields && tif->tif_nfields > 0) {\n\t\tuint32 i;\n\t\tfor (i = 0; i < tif->tif_nfields; i++) {\n\t\t\tTIFFField *fld = tif->tif_fields[i];\n\t\t\tif (fld->field_bit == FIELD_CUSTOM &&\n\t\t\t    strncmp("Tag ", fld->field_name, 4) == 0) {\n\t\t\t\t_TIFFfree(fld->field_name);\n\t\t\t\t_TIFFfree(fld);\n\t\t\t}\n\t\t}\n\t\t_TIFFfree(tif->tif_fields);\n\t}\n        if (tif->tif_nfieldscompat > 0) {\n                uint32 i;\n                for (i = 0; i < tif->tif_nfieldscompat; i++) {\n                        if (tif->tif_fieldscompat[i].allocated_size)\n                                _TIFFfree(tif->tif_fieldscompat[i].fields);\n                }\n                _TIFFfree(tif->tif_fieldscompat);\n        }\n\t_TIFFfree(tif);\n}', 'int\nTIFFFlush(TIFF* tif)\n{\n    if( tif->tif_mode == O_RDONLY )\n        return 1;\n    if (!TIFFFlushData(tif))\n        return (0);\n    if( (tif->tif_flags & TIFF_DIRTYSTRIP)\n        && !(tif->tif_flags & TIFF_DIRTYDIRECT)\n        && tif->tif_mode == O_RDWR )\n    {\n        uint64  *offsets=NULL, *sizes=NULL;\n        if( TIFFIsTiled(tif) )\n        {\n            if( TIFFGetField( tif, TIFFTAG_TILEOFFSETS, &offsets )\n                && TIFFGetField( tif, TIFFTAG_TILEBYTECOUNTS, &sizes )\n                && _TIFFRewriteField( tif, TIFFTAG_TILEOFFSETS, TIFF_LONG8,\n                                      tif->tif_dir.td_nstrips, offsets )\n                && _TIFFRewriteField( tif, TIFFTAG_TILEBYTECOUNTS, TIFF_LONG8,\n                                      tif->tif_dir.td_nstrips, sizes ) )\n            {\n                tif->tif_flags &= ~TIFF_DIRTYSTRIP;\n                tif->tif_flags &= ~TIFF_BEENWRITING;\n                return 1;\n            }\n        }\n        else\n        {\n            if( TIFFGetField( tif, TIFFTAG_STRIPOFFSETS, &offsets )\n                && TIFFGetField( tif, TIFFTAG_STRIPBYTECOUNTS, &sizes )\n                && _TIFFRewriteField( tif, TIFFTAG_STRIPOFFSETS, TIFF_LONG8,\n                                      tif->tif_dir.td_nstrips, offsets )\n                && _TIFFRewriteField( tif, TIFFTAG_STRIPBYTECOUNTS, TIFF_LONG8,\n                                      tif->tif_dir.td_nstrips, sizes ) )\n            {\n                tif->tif_flags &= ~TIFF_DIRTYSTRIP;\n                tif->tif_flags &= ~TIFF_BEENWRITING;\n                return 1;\n            }\n        }\n    }\n    if ((tif->tif_flags & (TIFF_DIRTYDIRECT|TIFF_DIRTYSTRIP))\n        && !TIFFRewriteDirectory(tif))\n        return (0);\n    return (1);\n}', 'int\nTIFFFlushData(TIFF* tif)\n{\n\tif ((tif->tif_flags & TIFF_BEENWRITING) == 0)\n\t\treturn (1);\n\tif (tif->tif_flags & TIFF_POSTENCODE) {\n\t\ttif->tif_flags &= ~TIFF_POSTENCODE;\n\t\tif (!(*tif->tif_postencode)(tif))\n\t\t\treturn (0);\n\t}\n\treturn (TIFFFlushData1(tif));\n}', 'int\nTIFFFlushData1(TIFF* tif)\n{\n\tif (tif->tif_rawcc > 0 && tif->tif_flags & TIFF_BUF4WRITE ) {\n\t\tif (!isFillOrder(tif, tif->tif_dir.td_fillorder) &&\n\t\t    (tif->tif_flags & TIFF_NOBITREV) == 0)\n\t\t\tTIFFReverseBits((uint8*)tif->tif_rawdata,\n\t\t\t    tif->tif_rawcc);\n\t\tif (!TIFFAppendToStrip(tif,\n\t\t    isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip,\n\t\t    tif->tif_rawdata, tif->tif_rawcc))\n\t\t\treturn (0);\n\t\ttif->tif_rawcc = 0;\n\t\ttif->tif_rawcp = tif->tif_rawdata;\n\t}\n\treturn (1);\n}', 'void\nTIFFReverseBits(uint8* cp, tmsize_t n)\n{\n\tfor (; n > 8; n -= 8) {\n\t\tcp[0] = TIFFBitRevTable[cp[0]];\n\t\tcp[1] = TIFFBitRevTable[cp[1]];\n\t\tcp[2] = TIFFBitRevTable[cp[2]];\n\t\tcp[3] = TIFFBitRevTable[cp[3]];\n\t\tcp[4] = TIFFBitRevTable[cp[4]];\n\t\tcp[5] = TIFFBitRevTable[cp[5]];\n\t\tcp[6] = TIFFBitRevTable[cp[6]];\n\t\tcp[7] = TIFFBitRevTable[cp[7]];\n\t\tcp += 8;\n\t}\n\twhile (n-- > 0)\n\t\t*cp = TIFFBitRevTable[*cp], cp++;\n}']