[skip ci] improve wrap_lines to correct buffer read overflow