fopen(3) returns NULL in case it can't open the STREAM. fgetln(3) returns NULL if it can't get a line from a STREAM. malloc returns NULL if it can't allocate memory.
actually is (which is usr.sbin/nmtree). This has tricked me numerous times.