How about checking here if the sum of `offset + length` doesn't exceed `size`?