Add a check on data pointer validity --kazu