Fix unchecked dynamic_cast warnings

CID 1130727-1130738