Fixed null pointer access in unit conversion