tools/tiff2pdf.c:1861: error: Null Dereference
  pointer `sbc` last assigned on line 1825 could be null and is dereferenced at line 1861, column 10.

tools/tiff2pdf.c:1823:1: start of procedure t2p_read_tiff_size()
1821. */
1822. 
1823. void t2p_read_tiff_size(T2P* t2p, TIFF* input){
      ^
1824. 
1825. 	uint64* sbc=NULL;

tools/tiff2pdf.c:1825:2: 
1823. void t2p_read_tiff_size(T2P* t2p, TIFF* input){
1824. 
1825. 	uint64* sbc=NULL;
       ^
1826. #if defined(JPEG_SUPPORT) || defined (OJPEG_SUPPORT)
1827. 	unsigned char* jpt=NULL;

tools/tiff2pdf.c:1827:2: 
1825. 	uint64* sbc=NULL;
1826. #if defined(JPEG_SUPPORT) || defined (OJPEG_SUPPORT)
1827. 	unsigned char* jpt=NULL;
       ^
1828. 	tstrip_t i=0;
1829. 	tstrip_t stripcount=0;

tools/tiff2pdf.c:1828:2: 
1826. #if defined(JPEG_SUPPORT) || defined (OJPEG_SUPPORT)
1827. 	unsigned char* jpt=NULL;
1828. 	tstrip_t i=0;
       ^
1829. 	tstrip_t stripcount=0;
1830. #endif

tools/tiff2pdf.c:1829:2: 
1827. 	unsigned char* jpt=NULL;
1828. 	tstrip_t i=0;
1829. 	tstrip_t stripcount=0;
       ^
1830. #endif
1831. #ifdef OJPEG_SUPPORT

tools/tiff2pdf.c:1832:9: 
1830. #endif
1831. #ifdef OJPEG_SUPPORT
1832.         tsize_t k = 0;
              ^
1833. #endif
1834. 

tools/tiff2pdf.c:1835:5: Taking true branch
1833. #endif
1834. 
1835. 	if(t2p->pdf_transcode == T2P_TRANSCODE_RAW){
          ^
1836. #ifdef CCITT_SUPPORT
1837. 		if(t2p->pdf_compression == T2P_COMPRESS_G4 ){

tools/tiff2pdf.c:1837:6: Taking false branch
1835. 	if(t2p->pdf_transcode == T2P_TRANSCODE_RAW){
1836. #ifdef CCITT_SUPPORT
1837. 		if(t2p->pdf_compression == T2P_COMPRESS_G4 ){
           ^
1838. 			TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc);
1839. 			t2p->tiff_datasize=sbc[0];

tools/tiff2pdf.c:1844:6: Taking false branch
1842. #endif
1843. #ifdef ZIP_SUPPORT
1844. 		if(t2p->pdf_compression == T2P_COMPRESS_ZIP){
           ^
1845. 			TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc);
1846. 			t2p->tiff_datasize=sbc[0];

tools/tiff2pdf.c:1851:6: Taking true branch
1849. #endif
1850. #ifdef OJPEG_SUPPORT
1851. 		if(t2p->tiff_compression == COMPRESSION_OJPEG){
           ^
1852. 			if(!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)){
1853. 				TIFFError(TIFF2PDF_MODULE, 

tools/tiff2pdf.c:1852:8: 
1850. #ifdef OJPEG_SUPPORT
1851. 		if(t2p->tiff_compression == COMPRESSION_OJPEG){
1852. 			if(!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)){
             ^
1853. 				TIFFError(TIFF2PDF_MODULE, 
1854. 					"Input file %s missing field: TIFFTAG_STRIPBYTECOUNTS",

libtiff/tif_dir.c:1029:1: start of procedure TIFFGetField()
  1027.  * internal directory structure.
  1028.  */
  1029. int
        ^
  1030. TIFFGetField(TIFF* tif, uint32 tag, ...)
  1031. {

libtiff/tif_dir.c:1035:2: 
  1033. 	va_list ap;
  1034. 
  1035. 	va_start(ap, tag);
         ^
  1036. 	status = TIFFVGetField(tif, tag, ap);
  1037. 	va_end(ap);

libtiff/tif_dir.c:1036:2: Skipping TIFFVGetField(): empty list of specs
  1034. 
  1035. 	va_start(ap, tag);
  1036. 	status = TIFFVGetField(tif, tag, ap);
         ^
  1037. 	va_end(ap);
  1038. 	return (status);

libtiff/tif_dir.c:1037:2: 
  1035. 	va_start(ap, tag);
  1036. 	status = TIFFVGetField(tif, tag, ap);
  1037. 	va_end(ap);
         ^
  1038. 	return (status);
  1039. }

libtiff/tif_dir.c:1038:2: 
  1036. 	status = TIFFVGetField(tif, tag, ap);
  1037. 	va_end(ap);
  1038. 	return (status);
         ^
  1039. }
  1040. 

libtiff/tif_dir.c:1039:1: return from a call to TIFFGetField
  1037. 	va_end(ap);
  1038. 	return (status);
  1039. }
        ^
  1040. 
  1041. /*

tools/tiff2pdf.c:1852:8: Taking false branch
1850. #ifdef OJPEG_SUPPORT
1851. 		if(t2p->tiff_compression == COMPRESSION_OJPEG){
1852. 			if(!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)){
             ^
1853. 				TIFFError(TIFF2PDF_MODULE, 
1854. 					"Input file %s missing field: TIFFTAG_STRIPBYTECOUNTS",

tools/tiff2pdf.c:1859:4: 
1857. 				return;
1858. 			}
1859. 			stripcount=TIFFNumberOfStrips(input);
         ^
1860. 			for(i=0;i<stripcount;i++){
1861. 				k += sbc[i];

libtiff/tif_strip.c:86:1: start of procedure TIFFNumberOfStrips()
  84.  * Compute how many strips are in an image.
  85.  */
  86. uint32
      ^
  87. TIFFNumberOfStrips(TIFF* tif)
  88. {

libtiff/tif_strip.c:89:2: 
  87. TIFFNumberOfStrips(TIFF* tif)
  88. {
  89. 	TIFFDirectory *td = &tif->tif_dir;
       ^
  90. 	uint32 nstrips;
  91. 

libtiff/tif_strip.c:92:13: Condition is false
  90. 	uint32 nstrips;
  91. 
  92. 	nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :
                  ^
  93. 	     TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));
  94. 	if (td->td_planarconfig == PLANARCONFIG_SEPARATE)

libtiff/tif_strip.c:92:2: 
  90. 	uint32 nstrips;
  91. 
  92. 	nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :
       ^
  93. 	     TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));
  94. 	if (td->td_planarconfig == PLANARCONFIG_SEPARATE)

libtiff/tif_strip.c:94:6: Taking true branch
  92. 	nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :
  93. 	     TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));
  94. 	if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
           ^
  95. 		nstrips = multiply_32(tif, nstrips, (uint32)td->td_samplesperpixel,
  96. 		    "TIFFNumberOfStrips");

libtiff/tif_strip.c:95:3: 
  93. 	     TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));
  94. 	if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
  95. 		nstrips = multiply_32(tif, nstrips, (uint32)td->td_samplesperpixel,
        ^
  96. 		    "TIFFNumberOfStrips");
  97. 	return (nstrips);

libtiff/tif_strip.c:34:1: start of procedure multiply_32()
    32. #include "tiffiop.h"
    33. 
    34. static uint32
        ^
    35. multiply_32(TIFF* tif, uint32 nmemb, uint32 elem_size, const char* where)
    36. {

libtiff/tif_strip.c:37:2: 
    35. multiply_32(TIFF* tif, uint32 nmemb, uint32 elem_size, const char* where)
    36. {
    37. 	uint32 bytes = nmemb * elem_size;
         ^
    38. 
    39. 	if (elem_size && bytes / elem_size != nmemb) {

libtiff/tif_strip.c:39:6: Taking true branch
    37. 	uint32 bytes = nmemb * elem_size;
    38. 
    39. 	if (elem_size && bytes / elem_size != nmemb) {
             ^
    40. 		TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Integer overflow in %s", where);
    41. 		bytes = 0;

libtiff/tif_strip.c:39:19: Taking false branch
    37. 	uint32 bytes = nmemb * elem_size;
    38. 
    39. 	if (elem_size && bytes / elem_size != nmemb) {
                          ^
    40. 		TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Integer overflow in %s", where);
    41. 		bytes = 0;

libtiff/tif_strip.c:44:2: 
    42. 	}
    43. 
    44. 	return (bytes);
         ^
    45. }
    46. 

libtiff/tif_strip.c:45:1: return from a call to multiply_32
    43. 
    44. 	return (bytes);
    45. }
        ^
    46. 
    47. static uint64

libtiff/tif_strip.c:97:2: 
  95. 		nstrips = multiply_32(tif, nstrips, (uint32)td->td_samplesperpixel,
  96. 		    "TIFFNumberOfStrips");
  97. 	return (nstrips);
       ^
  98. }
  99. 

libtiff/tif_strip.c:98:1: return from a call to TIFFNumberOfStrips
   96. 		    "TIFFNumberOfStrips");
   97. 	return (nstrips);
   98. }
       ^
   99. 
  100. /*

tools/tiff2pdf.c:1860:8: 
1858. 			}
1859. 			stripcount=TIFFNumberOfStrips(input);
1860. 			for(i=0;i<stripcount;i++){
             ^
1861. 				k += sbc[i];
1862. 			}

tools/tiff2pdf.c:1860:12: Loop condition is true. Entering loop body
1858. 			}
1859. 			stripcount=TIFFNumberOfStrips(input);
1860. 			for(i=0;i<stripcount;i++){
                 ^
1861. 				k += sbc[i];
1862. 			}

tools/tiff2pdf.c:1861:5: 
1859. 			stripcount=TIFFNumberOfStrips(input);
1860. 			for(i=0;i<stripcount;i++){
1861. 				k += sbc[i];
          ^
1862. 			}
1863. 			if(TIFFGetField(input, TIFFTAG_JPEGIFOFFSET, &(t2p->tiff_dataoffset))){

void t2p_read_tiff_size(T2P* t2p, TIFF* input){
	uint64* sbc=NULL;
#if defined(JPEG_SUPPORT) || defined (OJPEG_SUPPORT)
	unsigned char* jpt=NULL;
	tstrip_t i=0;
	tstrip_t stripcount=0;
#endif
#ifdef OJPEG_SUPPORT
        tsize_t k = 0;
#endif
	if(t2p->pdf_transcode == T2P_TRANSCODE_RAW){
#ifdef CCITT_SUPPORT
		if(t2p->pdf_compression == T2P_COMPRESS_G4 ){
			TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc);
			t2p->tiff_datasize=sbc[0];
			return;
		}
#endif
#ifdef ZIP_SUPPORT
		if(t2p->pdf_compression == T2P_COMPRESS_ZIP){
			TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc);
			t2p->tiff_datasize=sbc[0];
			return;
		}
#endif
#ifdef OJPEG_SUPPORT
		if(t2p->tiff_compression == COMPRESSION_OJPEG){
			if(!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)){
				TIFFError(TIFF2PDF_MODULE,
					"Input file %s missing field: TIFFTAG_STRIPBYTECOUNTS",
					TIFFFileName(input));
				t2p->t2p_error = T2P_ERR_ERROR;
				return;
			}
			stripcount=TIFFNumberOfStrips(input);
			for(i=0;i<stripcount;i++){
				k += sbc[i];
			}
			if(TIFFGetField(input, TIFFTAG_JPEGIFOFFSET, &(t2p->tiff_dataoffset))){
				if(t2p->tiff_dataoffset != 0){
					if(TIFFGetField(input, TIFFTAG_JPEGIFBYTECOUNT, &(t2p->tiff_datasize))!=0){
						if(t2p->tiff_datasize < k) {
							t2p->pdf_ojpegiflength=t2p->tiff_datasize;
							t2p->tiff_datasize+=k;
							t2p->tiff_datasize+=6;
							t2p->tiff_datasize+=2*stripcount;
							TIFFWarning(TIFF2PDF_MODULE,
								"Input file %s has short JPEG interchange file byte count",
								TIFFFileName(input));
							return;
						}
						return;
					}else {
						TIFFError(TIFF2PDF_MODULE,
							"Input file %s missing field: TIFFTAG_JPEGIFBYTECOUNT",
							TIFFFileName(input));
							t2p->t2p_error = T2P_ERR_ERROR;
							return;
					}
				}
			}
			t2p->tiff_datasize+=k;
			t2p->tiff_datasize+=2*stripcount;
			t2p->tiff_datasize+=2048;
			return;
		}
#endif
#ifdef JPEG_SUPPORT
		if(t2p->tiff_compression == COMPRESSION_JPEG) {
			uint32 count = 0;
			if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0 ){
				if(count > 4){
					t2p->tiff_datasize += count;
					t2p->tiff_datasize -= 2;
				}
			} else {
				t2p->tiff_datasize = 2;
			}
			stripcount=TIFFNumberOfStrips(input);
			if(!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)){
				TIFFError(TIFF2PDF_MODULE,
					"Input file %s missing field: TIFFTAG_STRIPBYTECOUNTS",
					TIFFFileName(input));
				t2p->t2p_error = T2P_ERR_ERROR;
				return;
			}
			for(i=0;i<stripcount;i++){
				t2p->tiff_datasize += sbc[i];
				t2p->tiff_datasize -=4;
			}
			t2p->tiff_datasize +=2;
		}
#endif
		(void) 0;
	}
	t2p->tiff_datasize=TIFFScanlineSize(input) * t2p->tiff_length;
	if(t2p->tiff_planar==PLANARCONFIG_SEPARATE){
		t2p->tiff_datasize*= t2p->tiff_samplesperpixel;
	}
	return;
}
['void t2p_read_tiff_size(T2P* t2p, TIFF* input){\n\tuint64* sbc=NULL;\n#if defined(JPEG_SUPPORT) || defined (OJPEG_SUPPORT)\n\tunsigned char* jpt=NULL;\n\ttstrip_t i=0;\n\ttstrip_t stripcount=0;\n#endif\n#ifdef OJPEG_SUPPORT\n        tsize_t k = 0;\n#endif\n\tif(t2p->pdf_transcode == T2P_TRANSCODE_RAW){\n#ifdef CCITT_SUPPORT\n\t\tif(t2p->pdf_compression == T2P_COMPRESS_G4 ){\n\t\t\tTIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc);\n\t\t\tt2p->tiff_datasize=sbc[0];\n\t\t\treturn;\n\t\t}\n#endif\n#ifdef ZIP_SUPPORT\n\t\tif(t2p->pdf_compression == T2P_COMPRESS_ZIP){\n\t\t\tTIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc);\n\t\t\tt2p->tiff_datasize=sbc[0];\n\t\t\treturn;\n\t\t}\n#endif\n#ifdef OJPEG_SUPPORT\n\t\tif(t2p->tiff_compression == COMPRESSION_OJPEG){\n\t\t\tif(!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)){\n\t\t\t\tTIFFError(TIFF2PDF_MODULE,\n\t\t\t\t\t"Input file %s missing field: TIFFTAG_STRIPBYTECOUNTS",\n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstripcount=TIFFNumberOfStrips(input);\n\t\t\tfor(i=0;i<stripcount;i++){\n\t\t\t\tk += sbc[i];\n\t\t\t}\n\t\t\tif(TIFFGetField(input, TIFFTAG_JPEGIFOFFSET, &(t2p->tiff_dataoffset))){\n\t\t\t\tif(t2p->tiff_dataoffset != 0){\n\t\t\t\t\tif(TIFFGetField(input, TIFFTAG_JPEGIFBYTECOUNT, &(t2p->tiff_datasize))!=0){\n\t\t\t\t\t\tif(t2p->tiff_datasize < k) {\n\t\t\t\t\t\t\tt2p->pdf_ojpegiflength=t2p->tiff_datasize;\n\t\t\t\t\t\t\tt2p->tiff_datasize+=k;\n\t\t\t\t\t\t\tt2p->tiff_datasize+=6;\n\t\t\t\t\t\t\tt2p->tiff_datasize+=2*stripcount;\n\t\t\t\t\t\t\tTIFFWarning(TIFF2PDF_MODULE,\n\t\t\t\t\t\t\t\t"Input file %s has short JPEG interchange file byte count",\n\t\t\t\t\t\t\t\tTIFFFileName(input));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}else {\n\t\t\t\t\t\tTIFFError(TIFF2PDF_MODULE,\n\t\t\t\t\t\t\t"Input file %s missing field: TIFFTAG_JPEGIFBYTECOUNT",\n\t\t\t\t\t\t\tTIFFFileName(input));\n\t\t\t\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tt2p->tiff_datasize+=k;\n\t\t\tt2p->tiff_datasize+=2*stripcount;\n\t\t\tt2p->tiff_datasize+=2048;\n\t\t\treturn;\n\t\t}\n#endif\n#ifdef JPEG_SUPPORT\n\t\tif(t2p->tiff_compression == COMPRESSION_JPEG) {\n\t\t\tuint32 count = 0;\n\t\t\tif(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0 ){\n\t\t\t\tif(count > 4){\n\t\t\t\t\tt2p->tiff_datasize += count;\n\t\t\t\t\tt2p->tiff_datasize -= 2;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tt2p->tiff_datasize = 2;\n\t\t\t}\n\t\t\tstripcount=TIFFNumberOfStrips(input);\n\t\t\tif(!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)){\n\t\t\t\tTIFFError(TIFF2PDF_MODULE,\n\t\t\t\t\t"Input file %s missing field: TIFFTAG_STRIPBYTECOUNTS",\n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor(i=0;i<stripcount;i++){\n\t\t\t\tt2p->tiff_datasize += sbc[i];\n\t\t\t\tt2p->tiff_datasize -=4;\n\t\t\t}\n\t\t\tt2p->tiff_datasize +=2;\n\t\t}\n#endif\n\t\t(void) 0;\n\t}\n\tt2p->tiff_datasize=TIFFScanlineSize(input) * t2p->tiff_length;\n\tif(t2p->tiff_planar==PLANARCONFIG_SEPARATE){\n\t\tt2p->tiff_datasize*= t2p->tiff_samplesperpixel;\n\t}\n\treturn;\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}', 'uint32\nTIFFNumberOfStrips(TIFF* tif)\n{\n\tTIFFDirectory *td = &tif->tif_dir;\n\tuint32 nstrips;\n\tnstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :\n\t     TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));\n\tif (td->td_planarconfig == PLANARCONFIG_SEPARATE)\n\t\tnstrips = multiply_32(tif, nstrips, (uint32)td->td_samplesperpixel,\n\t\t    "TIFFNumberOfStrips");\n\treturn (nstrips);\n}', 'static uint32\nmultiply_32(TIFF* tif, uint32 nmemb, uint32 elem_size, const char* where)\n{\n\tuint32 bytes = nmemb * elem_size;\n\tif (elem_size && bytes / elem_size != nmemb) {\n\t\tTIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Integer overflow in %s", where);\n\t\tbytes = 0;\n\t}\n\treturn (bytes);\n}']