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

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

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

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

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

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

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)

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

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