tools/thumbnail.c:616: error: Buffer Overrun L3
  Offset: [3, +oo] (⇐ [0, +oo] + 3) Size: [0, +oo] by call to `TIFFWriteDirectory`.

tools/thumbnail.c:563:1: Parameter `out->tif_dir.td_samplesperpixel`
561. }
562. 
563. static int
     ^
564. generateThumbnail(TIFF* in, TIFF* out)
565. {

tools/thumbnail.c:615:13: Call
613.     diroff[0] = 0UL;
614.     TIFFSetField(out, TIFFTAG_SUBIFD, 1, diroff);
615.     return (TIFFWriteEncodedStrip(out, 0, thumbnail, tnw*tnh) != -1 &&
                 ^
616.             TIFFWriteDirectory(out) != -1);
617. }

libtiff/tif_write.c:183:1: Parameter `tif->tif_dir.td_samplesperpixel`
  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/thumbnail.c:616:13: Call
614.     TIFFSetField(out, TIFFTAG_SUBIFD, 1, diroff);
615.     return (TIFFWriteEncodedStrip(out, 0, thumbnail, tnw*tnh) != -1 &&
616.             TIFFWriteDirectory(out) != -1);
                 ^
617. }
618. 

libtiff/tif_dirwrite.c:163:1: Parameter `tif->tif_dir.td_samplesperpixel`
  161.  * storage that's been changed.
  162.  */
  163. int
       ^
  164. TIFFWriteDirectory(TIFF* tif)
  165. {

libtiff/tif_dirwrite.c:166:9: Call
  164. TIFFWriteDirectory(TIFF* tif)
  165. {
  166. 	return TIFFWriteDirectorySec(tif,TRUE,TRUE,NULL);
               ^
  167. }
  168. 

libtiff/tif_dirwrite.c:345:1: Parameter `tif->tif_dir.td_samplesperpixel`
    343. }
    344. 
    345. static int
         ^
    346. TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff)
    347. {

libtiff/tif_dirwrite.c:555:10: Call
    553. 			if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE))
    554. 			{
    555. 				if (!TIFFWriteDirectoryTagSampleformatPerSample(tif,&ndir,dir,TIFFTAG_SMINSAMPLEVALUE,tif->tif_dir.td_sminsamplevalue))
                  ^
    556. 					goto bad;
    557. 			}

libtiff/tif_dirwrite.c:897:1: Parameter `tif->tif_dir.td_samplesperpixel`
      895. }
      896. 
      897. static int
           ^
      898. TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value)
      899. {

libtiff/tif_dirwrite.c:913:12: Call
      911. 				return(TIFFWriteDirectoryTagSshortPerSample(tif,ndir,dir,tag,(int16)value));
      912. 			else
      913. 				return(TIFFWriteDirectoryTagSlongPerSample(tif,ndir,dir,tag,(int32)value));
                      ^
      914. 		case SAMPLEFORMAT_UINT:
      915. 			if (tif->tif_dir.td_bitspersample<=8)

libtiff/tif_dirwrite.c:1218:1: Parameter `tif->tif_dir.td_samplesperpixel`
        1216. }
        1217. 
        1218. static int
              ^
        1219. TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value)
        1220. {

libtiff/tif_dirwrite.c:1231:4: Call
        1229. 		return(1);
        1230. 	}
        1231. 	m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int32));
                 ^
        1232. 	if (m==NULL)
        1233. 	{

libtiff/tif_unix.c:253:1: Parameter `s`
          251. #endif
          252. 
          253. void*
               ^
          254. _TIFFmalloc(tmsize_t s)
          255. {

libtiff/tif_unix.c:256:10: Array declaration
          254. _TIFFmalloc(tmsize_t s)
          255. {
          256. 	return (malloc((size_t) s));
                        ^
          257. }
          258. 

libtiff/tif_unix.c:256:2: Assignment
          254. _TIFFmalloc(tmsize_t s)
          255. {
          256. 	return (malloc((size_t) s));
                ^
          257. }
          258. 

libtiff/tif_dirwrite.c:1231:2: Assignment
        1229. 		return(1);
        1230. 	}
        1231. 	m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int32));
               ^
        1232. 	if (m==NULL)
        1233. 	{

libtiff/tif_dirwrite.c:1239:4: Call
        1237. 	for (na=m, nb=0; nb<tif->tif_dir.td_samplesperpixel; na++, nb++)
        1238. 		*na=value;
        1239. 	o=TIFFWriteDirectoryTagCheckedSlongArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m);
                 ^
        1240. 	_TIFFfree(m);
        1241. 	return(o);

libtiff/tif_dirwrite.c:1897:1: Parameter `*value`
          1895. #endif
          1896. 
          1897. static int
                ^
          1898. TIFFWriteDirectoryTagCheckedSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value)
          1899. {

libtiff/tif_dirwrite.c:1903:3: Call
          1901. 	assert(sizeof(int32)==4);
          1902. 	if (tif->tif_flags&TIFF_SWAB)
          1903. 		TIFFSwabArrayOfLong((uint32*)value,count);
                  ^
          1904. 	return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG,count,count*4,value));
          1905. }

libtiff/tif_swab.c:104:1: <Length trace>
102. 
103. #ifndef TIFFSwabArrayOfLong
104. void
     ^
105. TIFFSwabArrayOfLong(register uint32* lp, tmsize_t n)
106. {

libtiff/tif_swab.c:104:1: Parameter `*lp`
            102. 
            103. #ifndef TIFFSwabArrayOfLong
            104. void
                 ^
            105. TIFFSwabArrayOfLong(register uint32* lp, tmsize_t n)
            106. {

libtiff/tif_swab.c:112:3: Assignment
            110. 	/* XXX unroll loop some */
            111. 	while (n-- > 0) {
            112. 		cp = (unsigned char *)lp;
                   ^
            113. 		t = cp[3]; cp[3] = cp[0]; cp[0] = t;
            114. 		t = cp[2]; cp[2] = cp[1]; cp[1] = t;

libtiff/tif_swab.c:113:7: Array access: Offset: [3, +oo] (⇐ [0, +oo] + 3) Size: [0, +oo] by call to `TIFFWriteDirectory` 
            111. 	while (n-- > 0) {
            112. 		cp = (unsigned char *)lp;
            113. 		t = cp[3]; cp[3] = cp[0]; cp[0] = t;
                       ^
            114. 		t = cp[2]; cp[2] = cp[1]; cp[1] = t;
            115. 		lp++;
