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

libtiff/tif_getimage.c:2442:1: start of procedure setupMap()
2440.  * process also handles inverting B&W images when needed.
2441.  */ 
2442. static int
      ^
2443. setupMap(TIFFRGBAImage* img)
2444. {

libtiff/tif_getimage.c:2447:5: 
2445.     int32 x, range;
2446. 
2447.     range = (int32)((1L<<img->bitspersample)-1);
          ^
2448.     
2449.     /* treat 16 bit the same as eight bit */

libtiff/tif_getimage.c:2450:9: Taking false branch
2448.     
2449.     /* treat 16 bit the same as eight bit */
2450.     if( img->bitspersample == 16 )
              ^
2451.         range = (int32) 255;
2452. 

libtiff/tif_getimage.c:2453:5: 
2451.         range = (int32) 255;
2452. 
2453.     img->Map = (TIFFRGBValue*) _TIFFmalloc((range+1) * sizeof (TIFFRGBValue));
          ^
2454.     if (img->Map == NULL) {
2455. 		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:2454:9: Taking false branch
2452. 
2453.     img->Map = (TIFFRGBValue*) _TIFFmalloc((range+1) * sizeof (TIFFRGBValue));
2454.     if (img->Map == NULL) {
              ^
2455. 		TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif),
2456. 			"No space for photometric conversion table");

libtiff/tif_getimage.c:2459:9: Taking true branch
2457. 		return (0);
2458.     }
2459.     if (img->photometric == PHOTOMETRIC_MINISWHITE) {
              ^
2460. 	for (x = 0; x <= range; x++)
2461. 	    img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range);

libtiff/tif_getimage.c:2460:7: 
2458.     }
2459.     if (img->photometric == PHOTOMETRIC_MINISWHITE) {
2460. 	for (x = 0; x <= range; x++)
            ^
2461. 	    img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range);
2462.     } else {

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

libtiff/tif_getimage.c:2461:6: 
2459.     if (img->photometric == PHOTOMETRIC_MINISWHITE) {
2460. 	for (x = 0; x <= range; x++)
2461. 	    img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range);
           ^
2462.     } else {
2463. 	for (x = 0; x <= range; x++)

libtiff/tif_getimage.c:2460:26: 
2458.     }
2459.     if (img->photometric == PHOTOMETRIC_MINISWHITE) {
2460. 	for (x = 0; x <= range; x++)
                               ^
2461. 	    img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range);
2462.     } else {

libtiff/tif_getimage.c:2460:14: Loop condition is false. Leaving loop
2458.     }
2459.     if (img->photometric == PHOTOMETRIC_MINISWHITE) {
2460. 	for (x = 0; x <= range; x++)
                   ^
2461. 	    img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range);
2462.     } else {

libtiff/tif_getimage.c:2466:9: Taking true branch
2464. 	    img->Map[x] = (TIFFRGBValue) ((x * 255) / range);
2465.     }
2466.     if (img->bitspersample <= 16 &&
              ^
2467. 	(img->photometric == PHOTOMETRIC_MINISBLACK ||
2468. 	 img->photometric == PHOTOMETRIC_MINISWHITE)) {

libtiff/tif_getimage.c:2467:3: Taking false branch
2465.     }
2466.     if (img->bitspersample <= 16 &&
2467. 	(img->photometric == PHOTOMETRIC_MINISBLACK ||
        ^
2468. 	 img->photometric == PHOTOMETRIC_MINISWHITE)) {
2469. 	/*

libtiff/tif_getimage.c:2468:3: Taking true branch
2466.     if (img->bitspersample <= 16 &&
2467. 	(img->photometric == PHOTOMETRIC_MINISBLACK ||
2468. 	 img->photometric == PHOTOMETRIC_MINISWHITE)) {
        ^
2469. 	/*
2470. 	 * Use photometric mapping table to construct

libtiff/tif_getimage.c:2473:7: Skipping makebwmap(): empty list of specs
2471. 	 * unpacking tables for samples <= 8 bits.
2472. 	 */
2473. 	if (!makebwmap(img))
            ^
2474. 	    return (0);
2475. 	/* 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}']