libtiff/tif_getimage.c:2461: error: Memory Leak
  memory dynamically allocated by call to `_TIFFmalloc()` at line 2441, column 32 is not reachable after line 2461, column 7.

libtiff/tif_getimage.c:2430:1: start of procedure setupMap()
2428.  * process also handles inverting B&W images when needed.
2429.  */ 
2430. static int
      ^
2431. setupMap(TIFFRGBAImage* img)
2432. {

libtiff/tif_getimage.c:2435:5: 
2433.     int32 x, range;
2434. 
2435.     range = (int32)((1L<<img->bitspersample)-1);
          ^
2436.     
2437.     /* treat 16 bit the same as eight bit */

libtiff/tif_getimage.c:2438:9: Taking false branch
2436.     
2437.     /* treat 16 bit the same as eight bit */
2438.     if( img->bitspersample == 16 )
              ^
2439.         range = (int32) 255;
2440. 

libtiff/tif_getimage.c:2441:5: 
2439.         range = (int32) 255;
2440. 
2441.     img->Map = (TIFFRGBValue*) _TIFFmalloc((range+1) * sizeof (TIFFRGBValue));
          ^
2442.     if (img->Map == NULL) {
2443. 		TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif),

libtiff/tif_unix.c:308:1: start of procedure _TIFFmalloc()
  306. #endif
  307. 
  308. void*
       ^
  309. _TIFFmalloc(tmsize_t s)
  310. {

libtiff/tif_unix.c:311:13: Taking false branch
  309. _TIFFmalloc(tmsize_t s)
  310. {
  311.         if (s == 0)
                   ^
  312.                 return ((void *) NULL);
  313. 

libtiff/tif_unix.c:314:2: 
  312.                 return ((void *) NULL);
  313. 
  314. 	return (malloc((size_t) s));
        ^
  315. }
  316. 

libtiff/tif_unix.c:315:1: return from a call to _TIFFmalloc
  313. 
  314. 	return (malloc((size_t) s));
  315. }
       ^
  316. 
  317. void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz)

libtiff/tif_getimage.c:2442:9: Taking false branch
2440. 
2441.     img->Map = (TIFFRGBValue*) _TIFFmalloc((range+1) * sizeof (TIFFRGBValue));
2442.     if (img->Map == NULL) {
              ^
2443. 		TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif),
2444. 			"No space for photometric conversion table");

libtiff/tif_getimage.c:2447:9: Taking true branch
2445. 		return (0);
2446.     }
2447.     if (img->photometric == PHOTOMETRIC_MINISWHITE) {
              ^
2448. 	for (x = 0; x <= range; x++)
2449. 	    img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range);

libtiff/tif_getimage.c:2448:7: 
2446.     }
2447.     if (img->photometric == PHOTOMETRIC_MINISWHITE) {
2448. 	for (x = 0; x <= range; x++)
            ^
2449. 	    img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range);
2450.     } else {

libtiff/tif_getimage.c:2448:14: Loop condition is true. Entering loop body
2446.     }
2447.     if (img->photometric == PHOTOMETRIC_MINISWHITE) {
2448. 	for (x = 0; x <= range; x++)
                   ^
2449. 	    img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range);
2450.     } else {

libtiff/tif_getimage.c:2449:6: 
2447.     if (img->photometric == PHOTOMETRIC_MINISWHITE) {
2448. 	for (x = 0; x <= range; x++)
2449. 	    img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range);
           ^
2450.     } else {
2451. 	for (x = 0; x <= range; x++)

libtiff/tif_getimage.c:2448:26: 
2446.     }
2447.     if (img->photometric == PHOTOMETRIC_MINISWHITE) {
2448. 	for (x = 0; x <= range; x++)
                               ^
2449. 	    img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range);
2450.     } else {

libtiff/tif_getimage.c:2448:14: Loop condition is false. Leaving loop
2446.     }
2447.     if (img->photometric == PHOTOMETRIC_MINISWHITE) {
2448. 	for (x = 0; x <= range; x++)
                   ^
2449. 	    img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range);
2450.     } else {

libtiff/tif_getimage.c:2454:9: Taking true branch
2452. 	    img->Map[x] = (TIFFRGBValue) ((x * 255) / range);
2453.     }
2454.     if (img->bitspersample <= 16 &&
              ^
2455. 	(img->photometric == PHOTOMETRIC_MINISBLACK ||
2456. 	 img->photometric == PHOTOMETRIC_MINISWHITE)) {

libtiff/tif_getimage.c:2455:3: Taking false branch
2453.     }
2454.     if (img->bitspersample <= 16 &&
2455. 	(img->photometric == PHOTOMETRIC_MINISBLACK ||
        ^
2456. 	 img->photometric == PHOTOMETRIC_MINISWHITE)) {
2457. 	/*

libtiff/tif_getimage.c:2456:3: Taking true branch
2454.     if (img->bitspersample <= 16 &&
2455. 	(img->photometric == PHOTOMETRIC_MINISBLACK ||
2456. 	 img->photometric == PHOTOMETRIC_MINISWHITE)) {
        ^
2457. 	/*
2458. 	 * Use photometric mapping table to construct

libtiff/tif_getimage.c:2461:7: Skipping makebwmap(): empty list of specs
2459. 	 * unpacking tables for samples <= 8 bits.
2460. 	 */
2461. 	if (!makebwmap(img))
            ^
2462. 	    return (0);
2463. 	/* no longer need Map, free it */

static int
setupMap(TIFFRGBAImage* img)
{
    int32 x, range;
    range = (int32)((1L<<img->bitspersample)-1);
    if( img->bitspersample == 16 )
        range = (int32) 255;
    img->Map = (TIFFRGBValue*) _TIFFmalloc((range+1) * sizeof (TIFFRGBValue));
    if (img->Map == NULL) {
		TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif),
			"No space for photometric conversion table");
		return (0);
    }
    if (img->photometric == PHOTOMETRIC_MINISWHITE) {
	for (x = 0; x <= range; x++)
	    img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range);
    } else {
	for (x = 0; x <= range; x++)
	    img->Map[x] = (TIFFRGBValue) ((x * 255) / range);
    }
    if (img->bitspersample <= 16 &&
	(img->photometric == PHOTOMETRIC_MINISBLACK ||
	 img->photometric == PHOTOMETRIC_MINISWHITE)) {
	if (!makebwmap(img))
	    return (0);
	_TIFFfree(img->Map);
	img->Map = NULL;
    }
    return (1);
}
['static int\nsetupMap(TIFFRGBAImage* img)\n{\n    int32 x, range;\n    range = (int32)((1L<<img->bitspersample)-1);\n    if( img->bitspersample == 16 )\n        range = (int32) 255;\n    img->Map = (TIFFRGBValue*) _TIFFmalloc((range+1) * sizeof (TIFFRGBValue));\n    if (img->Map == NULL) {\n\t\tTIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif),\n\t\t\t"No space for photometric conversion table");\n\t\treturn (0);\n    }\n    if (img->photometric == PHOTOMETRIC_MINISWHITE) {\n\tfor (x = 0; x <= range; x++)\n\t    img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range);\n    } else {\n\tfor (x = 0; x <= range; x++)\n\t    img->Map[x] = (TIFFRGBValue) ((x * 255) / range);\n    }\n    if (img->bitspersample <= 16 &&\n\t(img->photometric == PHOTOMETRIC_MINISBLACK ||\n\t img->photometric == PHOTOMETRIC_MINISWHITE)) {\n\tif (!makebwmap(img))\n\t    return (0);\n\t_TIFFfree(img->Map);\n\timg->Map = NULL;\n    }\n    return (1);\n}', 'void*\n_TIFFmalloc(tmsize_t s)\n{\n        if (s == 0)\n                return ((void *) NULL);\n\treturn (malloc((size_t) s));\n}']