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:277:1: start of procedure _TIFFmalloc()
  275. #endif
  276. 
  277. void*
       ^
  278. _TIFFmalloc(tmsize_t s)
  279. {

libtiff/tif_unix.c:280:13: Taking false branch
  278. _TIFFmalloc(tmsize_t s)
  279. {
  280.         if (s == 0)
                   ^
  281.                 return ((void *) NULL);
  282. 

libtiff/tif_unix.c:283:2: 
  281.                 return ((void *) NULL);
  282. 
  283. 	return (malloc((size_t) s));
        ^
  284. }
  285. 

libtiff/tif_unix.c:284:1: return from a call to _TIFFmalloc
  282. 
  283. 	return (malloc((size_t) s));
  284. }
       ^
  285. 
  286. void

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. 	/*
