Had a strange issue just now. Although the value returned by
getenv was not
NULL, any attempts to access the memory pointed to by it resulted in segmentation fault.
The cause was the missing
#include <stdio.h> line, which is pretty easy to spot if you look at the build output.