tools/tiff2pdf.c:2133: error: Null Dereference
  pointer `tbc` last assigned on line 2109 could be null and is dereferenced at line 2133, column 6.

tools/tiff2pdf.c:2107:1: start of procedure t2p_read_tiff_size_tile()
2105. */
2106. 
2107. void t2p_read_tiff_size_tile(T2P* t2p, TIFF* input, ttile_t tile){
      ^
2108. 
2109. 	uint64* tbc = NULL;

tools/tiff2pdf.c:2109:2: 
2107. void t2p_read_tiff_size_tile(T2P* t2p, TIFF* input, ttile_t tile){
2108. 
2109. 	uint64* tbc = NULL;
       ^
2110. 	uint16 edge=0;
2111. #ifdef JPEG_SUPPORT

tools/tiff2pdf.c:2110:2: 
2108. 
2109. 	uint64* tbc = NULL;
2110. 	uint16 edge=0;
       ^
2111. #ifdef JPEG_SUPPORT
2112. 	unsigned char* jpt;

tools/tiff2pdf.c:2116:2: 
2114.         uint64 k;
2115. 
2116. 	edge |= t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile);
       ^
2117. 	edge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile);
2118. 	

tools/tiff2pdf.c:2181:1: start of procedure t2p_tile_is_right_edge()
  2179.  */
  2180. 
  2181. int t2p_tile_is_right_edge(T2P_TILES tiles, ttile_t tile){
        ^
  2182. 
  2183. 	if( ((tile+1) % tiles.tiles_tilecountx == 0) 

tools/tiff2pdf.c:2183:7: Taking false branch
  2181. int t2p_tile_is_right_edge(T2P_TILES tiles, ttile_t tile){
  2182. 
  2183. 	if( ((tile+1) % tiles.tiles_tilecountx == 0) 
              ^
  2184. 		&& (tiles.tiles_edgetilewidth != 0) ){
  2185. 		return(1);

tools/tiff2pdf.c:2187:3: 
  2185. 		return(1);
  2186. 	} else {
  2187. 		return(0);
          ^
  2188. 	}
  2189. }

tools/tiff2pdf.c:2189:1: return from a call to t2p_tile_is_right_edge
  2187. 		return(0);
  2188. 	}
  2189. }
        ^
  2190. 
  2191. /*

tools/tiff2pdf.c:2117:2: 
2115. 
2116. 	edge |= t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile);
2117. 	edge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile);
       ^
2118. 	
2119. 	if(t2p->pdf_transcode==T2P_TRANSCODE_RAW){

tools/tiff2pdf.c:2196:1: start of procedure t2p_tile_is_bottom_edge()
  2194.  */
  2195. 
  2196. int t2p_tile_is_bottom_edge(T2P_TILES tiles, ttile_t tile){
        ^
  2197. 
  2198. 	if( ((tile+1) > (tiles.tiles_tilecount-tiles.tiles_tilecountx) )

tools/tiff2pdf.c:2198:7: Taking false branch
  2196. int t2p_tile_is_bottom_edge(T2P_TILES tiles, ttile_t tile){
  2197. 
  2198. 	if( ((tile+1) > (tiles.tiles_tilecount-tiles.tiles_tilecountx) )
              ^
  2199. 		&& (tiles.tiles_edgetilelength != 0) ){
  2200. 		return(1);

tools/tiff2pdf.c:2202:3: 
  2200. 		return(1);
  2201. 	} else {
  2202. 		return(0);
          ^
  2203. 	}
  2204. }

tools/tiff2pdf.c:2204:1: return from a call to t2p_tile_is_bottom_edge
  2202. 		return(0);
  2203. 	}
  2204. }
        ^
  2205. 
  2206. /*

tools/tiff2pdf.c:2119:5: Taking true branch
2117. 	edge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile);
2118. 	
2119. 	if(t2p->pdf_transcode==T2P_TRANSCODE_RAW){
          ^
2120. 		if(edge
2121. #if defined(JPEG_SUPPORT) || defined(OJPEG_SUPPORT)

tools/tiff2pdf.c:2120:6: Taking false branch
2118. 	
2119. 	if(t2p->pdf_transcode==T2P_TRANSCODE_RAW){
2120. 		if(edge
           ^
2121. #if defined(JPEG_SUPPORT) || defined(OJPEG_SUPPORT)
2122. 		&& !(t2p->pdf_compression==T2P_COMPRESS_JPEG)

tools/tiff2pdf.c:2132:4: 
2130. 			return;
2131. 		} else {
2132. 			TIFFGetField(input, TIFFTAG_TILEBYTECOUNTS, &tbc);
         ^
2133. 			k=tbc[tile];
2134. #ifdef OJPEG_SUPPORT

libtiff/tif_dir.c:1269:1: start of procedure TIFFGetField()
  1267.  * internal directory structure.
  1268.  */
  1269. int
        ^
  1270. TIFFGetField(TIFF* tif, uint32 tag, ...)
  1271. {

libtiff/tif_dir.c:1275:2: 
  1273. 	va_list ap;
  1274. 
  1275. 	va_start(ap, tag);
         ^
  1276. 	status = TIFFVGetField(tif, tag, ap);
  1277. 	va_end(ap);

libtiff/tif_dir.c:1276:2: Skipping TIFFVGetField(): empty list of specs
  1274. 
  1275. 	va_start(ap, tag);
  1276. 	status = TIFFVGetField(tif, tag, ap);
         ^
  1277. 	va_end(ap);
  1278. 	return (status);

libtiff/tif_dir.c:1277:2: 
  1275. 	va_start(ap, tag);
  1276. 	status = TIFFVGetField(tif, tag, ap);
  1277. 	va_end(ap);
         ^
  1278. 	return (status);
  1279. }

libtiff/tif_dir.c:1278:2: 
  1276. 	status = TIFFVGetField(tif, tag, ap);
  1277. 	va_end(ap);
  1278. 	return (status);
         ^
  1279. }
  1280. 

libtiff/tif_dir.c:1279:1: return from a call to TIFFGetField
  1277. 	va_end(ap);
  1278. 	return (status);
  1279. }
        ^
  1280. 
  1281. /*

tools/tiff2pdf.c:2133:4: 
2131. 		} else {
2132. 			TIFFGetField(input, TIFFTAG_TILEBYTECOUNTS, &tbc);
2133. 			k=tbc[tile];
         ^
2134. #ifdef OJPEG_SUPPORT
2135. 			if(t2p->tiff_compression==COMPRESSION_OJPEG){

void t2p_read_tiff_size_tile(T2P* t2p, TIFF* input, ttile_t tile){
	uint64* tbc = NULL;
	uint16 edge=0;
#ifdef JPEG_SUPPORT
	unsigned char* jpt;
#endif
        uint64 k;
	edge |= t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile);
	edge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile);
	if(t2p->pdf_transcode==T2P_TRANSCODE_RAW){
		if(edge
#if defined(JPEG_SUPPORT) || defined(OJPEG_SUPPORT)
		&& !(t2p->pdf_compression==T2P_COMPRESS_JPEG)
#endif
		){
			t2p->tiff_datasize=TIFFTileSize(input);
			if (t2p->tiff_datasize == 0) {
				t2p->t2p_error = T2P_ERR_ERROR;
			}
			return;
		} else {
			TIFFGetField(input, TIFFTAG_TILEBYTECOUNTS, &tbc);
			k=tbc[tile];
#ifdef OJPEG_SUPPORT
			if(t2p->tiff_compression==COMPRESSION_OJPEG){
			  	k = checkAdd64(k, 2048, t2p);
			}
#endif
#ifdef JPEG_SUPPORT
			if(t2p->tiff_compression==COMPRESSION_JPEG) {
				uint32 count = 0;
				if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt)!=0){
					if(count > 4){
						k = checkAdd64(k, count, t2p);
						k -= 2;
					}
				}
			}
#endif
			t2p->tiff_datasize = (tsize_t) k;
			if ((uint64) t2p->tiff_datasize != k) {
				TIFFError(TIFF2PDF_MODULE, "Integer overflow");
				t2p->t2p_error = T2P_ERR_ERROR;
			}
			return;
		}
	}
	k = TIFFTileSize(input);
	if(t2p->tiff_planar==PLANARCONFIG_SEPARATE){
		k = checkMultiply64(k, t2p->tiff_samplesperpixel, t2p);
	}
	if (k == 0) {
		t2p->t2p_error = T2P_ERR_ERROR;
	}
	t2p->tiff_datasize = (tsize_t) k;
	if ((uint64) t2p->tiff_datasize != k) {
		TIFFError(TIFF2PDF_MODULE, "Integer overflow");
		t2p->t2p_error = T2P_ERR_ERROR;
	}
	return;
}
['void t2p_read_tiff_size_tile(T2P* t2p, TIFF* input, ttile_t tile){\n\tuint64* tbc = NULL;\n\tuint16 edge=0;\n#ifdef JPEG_SUPPORT\n\tunsigned char* jpt;\n#endif\n        uint64 k;\n\tedge |= t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile);\n\tedge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile);\n\tif(t2p->pdf_transcode==T2P_TRANSCODE_RAW){\n\t\tif(edge\n#if defined(JPEG_SUPPORT) || defined(OJPEG_SUPPORT)\n\t\t&& !(t2p->pdf_compression==T2P_COMPRESS_JPEG)\n#endif\n\t\t){\n\t\t\tt2p->tiff_datasize=TIFFTileSize(input);\n\t\t\tif (t2p->tiff_datasize == 0) {\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t}\n\t\t\treturn;\n\t\t} else {\n\t\t\tTIFFGetField(input, TIFFTAG_TILEBYTECOUNTS, &tbc);\n\t\t\tk=tbc[tile];\n#ifdef OJPEG_SUPPORT\n\t\t\tif(t2p->tiff_compression==COMPRESSION_OJPEG){\n\t\t\t  \tk = checkAdd64(k, 2048, t2p);\n\t\t\t}\n#endif\n#ifdef JPEG_SUPPORT\n\t\t\tif(t2p->tiff_compression==COMPRESSION_JPEG) {\n\t\t\t\tuint32 count = 0;\n\t\t\t\tif(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt)!=0){\n\t\t\t\t\tif(count > 4){\n\t\t\t\t\t\tk = checkAdd64(k, count, t2p);\n\t\t\t\t\t\tk -= 2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n#endif\n\t\t\tt2p->tiff_datasize = (tsize_t) k;\n\t\t\tif ((uint64) t2p->tiff_datasize != k) {\n\t\t\t\tTIFFError(TIFF2PDF_MODULE, "Integer overflow");\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n\tk = TIFFTileSize(input);\n\tif(t2p->tiff_planar==PLANARCONFIG_SEPARATE){\n\t\tk = checkMultiply64(k, t2p->tiff_samplesperpixel, t2p);\n\t}\n\tif (k == 0) {\n\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t}\n\tt2p->tiff_datasize = (tsize_t) k;\n\tif ((uint64) t2p->tiff_datasize != k) {\n\t\tTIFFError(TIFF2PDF_MODULE, "Integer overflow");\n\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t}\n\treturn;\n}', 'int t2p_tile_is_right_edge(T2P_TILES tiles, ttile_t tile){\n\tif( ((tile+1) % tiles.tiles_tilecountx == 0)\n\t\t&& (tiles.tiles_edgetilewidth != 0) ){\n\t\treturn(1);\n\t} else {\n\t\treturn(0);\n\t}\n}', 'int t2p_tile_is_bottom_edge(T2P_TILES tiles, ttile_t tile){\n\tif( ((tile+1) > (tiles.tiles_tilecount-tiles.tiles_tilecountx) )\n\t\t&& (tiles.tiles_edgetilelength != 0) ){\n\t\treturn(1);\n\t} else {\n\t\treturn(0);\n\t}\n}', 'int\nTIFFGetField(TIFF* tif, uint32 tag, ...)\n{\n\tint status;\n\tva_list ap;\n\tva_start(ap, tag);\n\tstatus = TIFFVGetField(tif, tag, ap);\n\tva_end(ap);\n\treturn (status);\n}']