[cppcheck] Fix buffer access out-of-bound in add_line_to