Avoid integer overflows with very long strings