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

tools/tiffmedian.c:617:1: start of procedure create_colorcell()
615. }
616. 
617. static C_cell *
     ^
618. create_colorcell(int red, int green, int blue)
619. {

tools/tiffmedian.c:625:2: 
623. 	register int tmp, dist, n;
624. 
625. 	ir = red >> (COLOR_DEPTH-C_DEPTH);
      ^
626. 	ig = green >> (COLOR_DEPTH-C_DEPTH);
627. 	ib = blue >> (COLOR_DEPTH-C_DEPTH);

tools/tiffmedian.c:626:2: 
624. 
625. 	ir = red >> (COLOR_DEPTH-C_DEPTH);
626. 	ig = green >> (COLOR_DEPTH-C_DEPTH);
      ^
627. 	ib = blue >> (COLOR_DEPTH-C_DEPTH);
628. 	ptr = (C_cell *)_TIFFmalloc(sizeof (C_cell));

tools/tiffmedian.c:627:2: 
625. 	ir = red >> (COLOR_DEPTH-C_DEPTH);
626. 	ig = green >> (COLOR_DEPTH-C_DEPTH);
627. 	ib = blue >> (COLOR_DEPTH-C_DEPTH);
      ^
628. 	ptr = (C_cell *)_TIFFmalloc(sizeof (C_cell));
629. 	*(ColorCells + ir*C_LEN*C_LEN + ig*C_LEN + ib) = ptr;

tools/tiffmedian.c:628:2: 
626. 	ig = green >> (COLOR_DEPTH-C_DEPTH);
627. 	ib = blue >> (COLOR_DEPTH-C_DEPTH);
628. 	ptr = (C_cell *)_TIFFmalloc(sizeof (C_cell));
      ^
629. 	*(ColorCells + ir*C_LEN*C_LEN + ig*C_LEN + ib) = ptr;
630. 	ptr->num_ents = 0;

libtiff/tif_unix.c:253:1: start of procedure _TIFFmalloc()
  251. #endif
  252. 
  253. void*
       ^
  254. _TIFFmalloc(tmsize_t s)
  255. {

libtiff/tif_unix.c:256:2: 
  254. _TIFFmalloc(tmsize_t s)
  255. {
  256. 	return (malloc((size_t) s));
        ^
  257. }
  258. 

libtiff/tif_unix.c:257:1: return from a call to _TIFFmalloc
  255. {
  256. 	return (malloc((size_t) s));
  257. }
       ^
  258. 
  259. void

tools/tiffmedian.c:629:2: 
627. 	ib = blue >> (COLOR_DEPTH-C_DEPTH);
628. 	ptr = (C_cell *)_TIFFmalloc(sizeof (C_cell));
629. 	*(ColorCells + ir*C_LEN*C_LEN + ig*C_LEN + ib) = ptr;
      ^
630. 	ptr->num_ents = 0;
631. 

tools/tiffmedian.c:630:2: 
628. 	ptr = (C_cell *)_TIFFmalloc(sizeof (C_cell));
629. 	*(ColorCells + ir*C_LEN*C_LEN + ig*C_LEN + ib) = ptr;
630. 	ptr->num_ents = 0;
      ^
631. 
632. 	/*
