fix in dyn_cast issue for null pointer checking