Fix length calculation for null strings