Bug 939141 followup: don't crash on null pointers. 

I thought valid() was sufficient, but apparently this method can also return null.