Check for null pointer before copy an array