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

tools/tiff2pdf.c:2065:1: start of procedure t2p_read_tiff_size_tile()
2063. */
2064. 
2065. void t2p_read_tiff_size_tile(T2P* t2p, TIFF* input, ttile_t tile){
      ^
2066. 
2067. 	uint64* tbc = NULL;

tools/tiff2pdf.c:2067:2: 
2065. void t2p_read_tiff_size_tile(T2P* t2p, TIFF* input, ttile_t tile){
2066. 
2067. 	uint64* tbc = NULL;
       ^
2068. 	uint16 edge=0;
2069. #ifdef JPEG_SUPPORT

tools/tiff2pdf.c:2068:2: 
2066. 
2067. 	uint64* tbc = NULL;
2068. 	uint16 edge=0;
       ^
2069. #ifdef JPEG_SUPPORT
2070. 	unsigned char* jpt;

tools/tiff2pdf.c:2074:2: 
2072.         uint64 k;
2073. 
2074. 	edge |= t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile);
       ^
2075. 	edge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile);
2076. 	

tools/tiff2pdf.c:2139:1: start of procedure t2p_tile_is_right_edge()
  2137.  */
  2138. 
  2139. int t2p_tile_is_right_edge(T2P_TILES tiles, ttile_t tile){
        ^
  2140. 
  2141. 	if( ((tile+1) % tiles.tiles_tilecountx == 0) 

tools/tiff2pdf.c:2141:7: Taking false branch
  2139. int t2p_tile_is_right_edge(T2P_TILES tiles, ttile_t tile){
  2140. 
  2141. 	if( ((tile+1) % tiles.tiles_tilecountx == 0) 
              ^
  2142. 		&& (tiles.tiles_edgetilewidth != 0) ){
  2143. 		return(1);

tools/tiff2pdf.c:2145:3: 
  2143. 		return(1);
  2144. 	} else {
  2145. 		return(0);
          ^
  2146. 	}
  2147. }

tools/tiff2pdf.c:2147:1: return from a call to t2p_tile_is_right_edge
  2145. 		return(0);
  2146. 	}
  2147. }
        ^
  2148. 
  2149. /*

tools/tiff2pdf.c:2075:2: 
2073. 
2074. 	edge |= t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile);
2075. 	edge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile);
       ^
2076. 	
2077. 	if(t2p->pdf_transcode==T2P_TRANSCODE_RAW){

tools/tiff2pdf.c:2154:1: start of procedure t2p_tile_is_bottom_edge()
  2152.  */
  2153. 
  2154. int t2p_tile_is_bottom_edge(T2P_TILES tiles, ttile_t tile){
        ^
  2155. 
  2156. 	if( ((tile+1) > (tiles.tiles_tilecount-tiles.tiles_tilecountx) )

tools/tiff2pdf.c:2156:7: Taking false branch
  2154. int t2p_tile_is_bottom_edge(T2P_TILES tiles, ttile_t tile){
  2155. 
  2156. 	if( ((tile+1) > (tiles.tiles_tilecount-tiles.tiles_tilecountx) )
              ^
  2157. 		&& (tiles.tiles_edgetilelength != 0) ){
  2158. 		return(1);

tools/tiff2pdf.c:2160:3: 
  2158. 		return(1);
  2159. 	} else {
  2160. 		return(0);
          ^
  2161. 	}
  2162. }

tools/tiff2pdf.c:2162:1: return from a call to t2p_tile_is_bottom_edge
  2160. 		return(0);
  2161. 	}
  2162. }
        ^
  2163. 
  2164. /*

tools/tiff2pdf.c:2077:5: Taking true branch
2075. 	edge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile);
2076. 	
2077. 	if(t2p->pdf_transcode==T2P_TRANSCODE_RAW){
          ^
2078. 		if(edge
2079. #if defined(JPEG_SUPPORT) || defined(OJPEG_SUPPORT)

tools/tiff2pdf.c:2078:6: Taking false branch
2076. 	
2077. 	if(t2p->pdf_transcode==T2P_TRANSCODE_RAW){
2078. 		if(edge
           ^
2079. #if defined(JPEG_SUPPORT) || defined(OJPEG_SUPPORT)
2080. 		&& !(t2p->pdf_compression==T2P_COMPRESS_JPEG)

tools/tiff2pdf.c:2090:4: 
2088. 			return;
2089. 		} else {
2090. 			TIFFGetField(input, TIFFTAG_TILEBYTECOUNTS, &tbc);
         ^
2091. 			k=tbc[tile];
2092. #ifdef OJPEG_SUPPORT

libtiff/tif_dir.c:1214:1: start of procedure TIFFGetField()
  1212.  * internal directory structure.
  1213.  */
  1214. int
        ^
  1215. TIFFGetField(TIFF* tif, uint32 tag, ...)
  1216. {

libtiff/tif_dir.c:1220:2: 
  1218. 	va_list ap;
  1219. 
  1220. 	va_start(ap, tag);
         ^
  1221. 	status = TIFFVGetField(tif, tag, ap);
  1222. 	va_end(ap);

libtiff/tif_dir.c:1221:2: Skipping TIFFVGetField(): empty list of specs
  1219. 
  1220. 	va_start(ap, tag);
  1221. 	status = TIFFVGetField(tif, tag, ap);
         ^
  1222. 	va_end(ap);
  1223. 	return (status);

libtiff/tif_dir.c:1222:2: 
  1220. 	va_start(ap, tag);
  1221. 	status = TIFFVGetField(tif, tag, ap);
  1222. 	va_end(ap);
         ^
  1223. 	return (status);
  1224. }

libtiff/tif_dir.c:1223:2: 
  1221. 	status = TIFFVGetField(tif, tag, ap);
  1222. 	va_end(ap);
  1223. 	return (status);
         ^
  1224. }
  1225. 

libtiff/tif_dir.c:1224:1: return from a call to TIFFGetField
  1222. 	va_end(ap);
  1223. 	return (status);
  1224. }
        ^
  1225. 
  1226. /*

tools/tiff2pdf.c:2091:4: 
2089. 		} else {
2090. 			TIFFGetField(input, TIFFTAG_TILEBYTECOUNTS, &tbc);
2091. 			k=tbc[tile];
         ^
2092. #ifdef OJPEG_SUPPORT
2093. 			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}']