tools/tiff2ps.c:1900: error: Null Dereference
  pointer `tf_buf` last assigned on line 1899 could be null and is dereferenced by call to `memset()` at line 1900, column 9.

tools/tiff2ps.c:1884:1: start of procedure PSDataBW()
1882. }
1883. 
1884. void
      ^
1885. PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h)
1886. {

tools/tiff2ps.c:1887:2: 
1885. PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h)
1886. {
1887. 	int breaklen = MAXLINE;
       ^
1888. 	unsigned char* tf_buf;
1889. 	unsigned char* cp;

tools/tiff2ps.c:1890:2: 
1888. 	unsigned char* tf_buf;
1889. 	unsigned char* cp;
1890. 	tsize_t stripsize = TIFFStripSize(tif);
       ^
1891. 	tstrip_t s;
1892. 

libtiff/tif_strip.c:235:1: start of procedure TIFFStripSize()
  233. 	return (TIFFVStripSize64(tif, rps));
  234. }
  235. tmsize_t
       ^
  236. TIFFStripSize(TIFF* tif)
  237. {

libtiff/tif_strip.c:238:2: 
  236. TIFFStripSize(TIFF* tif)
  237. {
  238. 	static const char module[] = "TIFFStripSize";
        ^
  239. 	uint64 m;
  240. 	tmsize_t n;

libtiff/tif_strip.c:241:2: Skipping TIFFStripSize64(): empty list of specs
  239. 	uint64 m;
  240. 	tmsize_t n;
  241. 	m=TIFFStripSize64(tif);
        ^
  242. 	n=(tmsize_t)m;
  243. 	if ((uint64)n!=m)

libtiff/tif_strip.c:242:2: 
  240. 	tmsize_t n;
  241. 	m=TIFFStripSize64(tif);
  242. 	n=(tmsize_t)m;
        ^
  243. 	if ((uint64)n!=m)
  244. 	{

libtiff/tif_strip.c:243:6: Taking false branch
  241. 	m=TIFFStripSize64(tif);
  242. 	n=(tmsize_t)m;
  243. 	if ((uint64)n!=m)
            ^
  244. 	{
  245. 		TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");

libtiff/tif_strip.c:248:2: 
  246. 		n=0;
  247. 	}
  248. 	return(n);
        ^
  249. }
  250. 

libtiff/tif_strip.c:249:1: return from a call to TIFFStripSize
  247. 	}
  248. 	return(n);
  249. }
       ^
  250. 
  251. /*

tools/tiff2ps.c:1895:2: 
1893. #if defined( EXP_ASCII85ENCODER )
1894. 	tsize_t	ascii85_l;		/* Length, in bytes, of ascii85_p[] data */
1895. 	uint8	*ascii85_p = 0;		/* Holds ASCII85 encoded data */
       ^
1896. #endif
1897. 

tools/tiff2ps.c:1898:2: 
1896. #endif
1897. 
1898. 	(void) w; (void) h;
       ^
1899. 	tf_buf = (unsigned char *) _TIFFmalloc(stripsize);
1900.         memset(tf_buf, 0, stripsize);

tools/tiff2ps.c:1898:12: 
1896. #endif
1897. 
1898. 	(void) w; (void) h;
                 ^
1899. 	tf_buf = (unsigned char *) _TIFFmalloc(stripsize);
1900.         memset(tf_buf, 0, stripsize);

tools/tiff2ps.c:1899:2: 
1897. 
1898. 	(void) w; (void) h;
1899. 	tf_buf = (unsigned char *) _TIFFmalloc(stripsize);
       ^
1900.         memset(tf_buf, 0, stripsize);
1901. 	if (tf_buf == NULL) {

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

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

libtiff/tif_unix.c:257:1: return from a call to _TIFFmalloc
  255. {
  256. 	return (malloc((size_t) s));
  257. }
       ^
  258. 
  259. void

tools/tiff2ps.c:1900:9: 
1898. 	(void) w; (void) h;
1899. 	tf_buf = (unsigned char *) _TIFFmalloc(stripsize);
1900.         memset(tf_buf, 0, stripsize);
              ^
1901. 	if (tf_buf == NULL) {
1902. 		TIFFError(filename, "No space for scanline buffer");

void
PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h)
{
	int breaklen = MAXLINE;
	unsigned char* tf_buf;
	unsigned char* cp;
	tsize_t stripsize = TIFFStripSize(tif);
	tstrip_t s;
#if defined( EXP_ASCII85ENCODER )
	tsize_t	ascii85_l;
	uint8	*ascii85_p = 0;
#endif
	(void) w; (void) h;
	tf_buf = (unsigned char *) _TIFFmalloc(stripsize);
        memset(tf_buf, 0, stripsize);
	if (tf_buf == NULL) {
		TIFFError(filename, "No space for scanline buffer");
		return;
	}
#if defined( EXP_ASCII85ENCODER )
	if ( ascii85 ) {
	    ascii85_p = _TIFFmalloc( (stripsize+(stripsize/2)) + 8 );
	    if ( !ascii85_p ) {
		_TIFFfree( tf_buf );
		TIFFError( filename, "Cannot allocate ASCII85 encoding buffer." );
		return;
	    }
	}
#endif
	if (ascii85)
		Ascii85Init();
	for (s = 0; s < TIFFNumberOfStrips(tif); s++) {
		tmsize_t cc = TIFFReadEncodedStrip(tif, s, tf_buf, stripsize);
		if (cc < 0) {
			TIFFError(filename, "Can't read strip");
			break;
		}
		cp = tf_buf;
		if (photometric == PHOTOMETRIC_MINISWHITE) {
			for (cp += cc; --cp >= tf_buf;)
				*cp = ~*cp;
			cp++;
		}
		if (bitspersample == 16 && !HOST_BIGENDIAN) {
			PS_FlipBytes(cp, cc);
		}
		if (ascii85) {
#if defined( EXP_ASCII85ENCODER )
			if (alpha) {
				int adjust, i;
				for (i = 0; i < cc; i+=2) {
					adjust = 255 - cp[i + 1];
				    cp[i / 2] = cp[i] + adjust;
				}
				cc /= 2;
			}
			ascii85_l = Ascii85EncodeBlock( ascii85_p, 1, cp, cc );
			if ( ascii85_l > 0 )
			    fwrite( ascii85_p, ascii85_l, 1, fd );
#else
			while (cc-- > 0)
				Ascii85Put(*cp++, fd);
#endif
		} else {
			unsigned char c;
			if (alpha) {
				int adjust;
				while (cc-- > 0) {
					DOBREAK(breaklen, 1, fd);
					adjust = 255 - cp[1];
					c = *cp++ + adjust; PUTHEX(c,fd);
					cp++, cc--;
				}
			} else {
				while (cc-- > 0) {
					c = *cp++;
					DOBREAK(breaklen, 1, fd);
					PUTHEX(c, fd);
				}
			}
		}
	}
	if ( !ascii85 )
	{
	    if ( level2 || level3)
		fputs(">\n", fd);
	}
#if !defined( EXP_ASCII85ENCODER )
	else
	    Ascii85Flush(fd);
#else
	if ( ascii85_p )
	    _TIFFfree( ascii85_p );
#endif
	_TIFFfree(tf_buf);
}
['void\nPSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h)\n{\n\tint breaklen = MAXLINE;\n\tunsigned char* tf_buf;\n\tunsigned char* cp;\n\ttsize_t stripsize = TIFFStripSize(tif);\n\ttstrip_t s;\n#if defined( EXP_ASCII85ENCODER )\n\ttsize_t\tascii85_l;\n\tuint8\t*ascii85_p = 0;\n#endif\n\t(void) w; (void) h;\n\ttf_buf = (unsigned char *) _TIFFmalloc(stripsize);\n        memset(tf_buf, 0, stripsize);\n\tif (tf_buf == NULL) {\n\t\tTIFFError(filename, "No space for scanline buffer");\n\t\treturn;\n\t}\n#if defined( EXP_ASCII85ENCODER )\n\tif ( ascii85 ) {\n\t    ascii85_p = _TIFFmalloc( (stripsize+(stripsize/2)) + 8 );\n\t    if ( !ascii85_p ) {\n\t\t_TIFFfree( tf_buf );\n\t\tTIFFError( filename, "Cannot allocate ASCII85 encoding buffer." );\n\t\treturn;\n\t    }\n\t}\n#endif\n\tif (ascii85)\n\t\tAscii85Init();\n\tfor (s = 0; s < TIFFNumberOfStrips(tif); s++) {\n\t\ttmsize_t cc = TIFFReadEncodedStrip(tif, s, tf_buf, stripsize);\n\t\tif (cc < 0) {\n\t\t\tTIFFError(filename, "Can\'t read strip");\n\t\t\tbreak;\n\t\t}\n\t\tcp = tf_buf;\n\t\tif (photometric == PHOTOMETRIC_MINISWHITE) {\n\t\t\tfor (cp += cc; --cp >= tf_buf;)\n\t\t\t\t*cp = ~*cp;\n\t\t\tcp++;\n\t\t}\n\t\tif (bitspersample == 16 && !HOST_BIGENDIAN) {\n\t\t\tPS_FlipBytes(cp, cc);\n\t\t}\n\t\tif (ascii85) {\n#if defined( EXP_ASCII85ENCODER )\n\t\t\tif (alpha) {\n\t\t\t\tint adjust, i;\n\t\t\t\tfor (i = 0; i < cc; i+=2) {\n\t\t\t\t\tadjust = 255 - cp[i + 1];\n\t\t\t\t    cp[i / 2] = cp[i] + adjust;\n\t\t\t\t}\n\t\t\t\tcc /= 2;\n\t\t\t}\n\t\t\tascii85_l = Ascii85EncodeBlock( ascii85_p, 1, cp, cc );\n\t\t\tif ( ascii85_l > 0 )\n\t\t\t    fwrite( ascii85_p, ascii85_l, 1, fd );\n#else\n\t\t\twhile (cc-- > 0)\n\t\t\t\tAscii85Put(*cp++, fd);\n#endif\n\t\t} else {\n\t\t\tunsigned char c;\n\t\t\tif (alpha) {\n\t\t\t\tint adjust;\n\t\t\t\twhile (cc-- > 0) {\n\t\t\t\t\tDOBREAK(breaklen, 1, fd);\n\t\t\t\t\tadjust = 255 - cp[1];\n\t\t\t\t\tc = *cp++ + adjust; PUTHEX(c,fd);\n\t\t\t\t\tcp++, cc--;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\twhile (cc-- > 0) {\n\t\t\t\t\tc = *cp++;\n\t\t\t\t\tDOBREAK(breaklen, 1, fd);\n\t\t\t\t\tPUTHEX(c, fd);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif ( !ascii85 )\n\t{\n\t    if ( level2 || level3)\n\t\tfputs(">\\n", fd);\n\t}\n#if !defined( EXP_ASCII85ENCODER )\n\telse\n\t    Ascii85Flush(fd);\n#else\n\tif ( ascii85_p )\n\t    _TIFFfree( ascii85_p );\n#endif\n\t_TIFFfree(tf_buf);\n}', 'tmsize_t\nTIFFStripSize(TIFF* tif)\n{\n\tstatic const char module[] = "TIFFStripSize";\n\tuint64 m;\n\ttmsize_t n;\n\tm=TIFFStripSize64(tif);\n\tn=(tmsize_t)m;\n\tif ((uint64)n!=m)\n\t{\n\t\tTIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");\n\t\tn=0;\n\t}\n\treturn(n);\n}', 'void*\n_TIFFmalloc(tmsize_t s)\n{\n\treturn (malloc((size_t) s));\n}']