Silence CID 52142: check dynamic_cast NULL retval
Silence CID 52143: don't deref NULL ptr