tools/tiffmedian.c:638: error: Null Dereference
  pointer `ptr` last assigned on line 636 could be null and is dereferenced at line 638, column 2.

tools/tiffmedian.c:625:1: start of procedure create_colorcell()
623. }
624. 
625. static C_cell *
     ^
626. create_colorcell(int red, int green, int blue)
627. {

tools/tiffmedian.c:633:2: 
631. 	register int tmp, dist, n;
632. 
633. 	ir = red >> (COLOR_DEPTH-C_DEPTH);
      ^
634. 	ig = green >> (COLOR_DEPTH-C_DEPTH);
635. 	ib = blue >> (COLOR_DEPTH-C_DEPTH);

tools/tiffmedian.c:634:2: 
632. 
633. 	ir = red >> (COLOR_DEPTH-C_DEPTH);
634. 	ig = green >> (COLOR_DEPTH-C_DEPTH);
      ^
635. 	ib = blue >> (COLOR_DEPTH-C_DEPTH);
636. 	ptr = (C_cell *)_TIFFmalloc(sizeof (C_cell));

tools/tiffmedian.c:635:2: 
633. 	ir = red >> (COLOR_DEPTH-C_DEPTH);
634. 	ig = green >> (COLOR_DEPTH-C_DEPTH);
635. 	ib = blue >> (COLOR_DEPTH-C_DEPTH);
      ^
636. 	ptr = (C_cell *)_TIFFmalloc(sizeof (C_cell));
637. 	*(ColorCells + ir*C_LEN*C_LEN + ig*C_LEN + ib) = ptr;

tools/tiffmedian.c:636:2: 
634. 	ig = green >> (COLOR_DEPTH-C_DEPTH);
635. 	ib = blue >> (COLOR_DEPTH-C_DEPTH);
636. 	ptr = (C_cell *)_TIFFmalloc(sizeof (C_cell));
      ^
637. 	*(ColorCells + ir*C_LEN*C_LEN + ig*C_LEN + ib) = ptr;
638. 	ptr->num_ents = 0;

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

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

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

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

tools/tiffmedian.c:637:2: 
635. 	ib = blue >> (COLOR_DEPTH-C_DEPTH);
636. 	ptr = (C_cell *)_TIFFmalloc(sizeof (C_cell));
637. 	*(ColorCells + ir*C_LEN*C_LEN + ig*C_LEN + ib) = ptr;
      ^
638. 	ptr->num_ents = 0;
639. 

tools/tiffmedian.c:638:2: 
636. 	ptr = (C_cell *)_TIFFmalloc(sizeof (C_cell));
637. 	*(ColorCells + ir*C_LEN*C_LEN + ig*C_LEN + ib) = ptr;
638. 	ptr->num_ents = 0;
      ^
639. 
640. 	/*
