I mean that the least you can do before pointer dereference is just check for several bad sentinel values, NULL being one of them.
Seems like a rather amateur mistake to me.
I've been an idiot as well in the past. Happily some of us actually learn though!