Sat 14 Jan 2017 11:01:03 PM UTC, original submission:
(Taken from patch #9215.)
Steps to reproduce are as follows:
1. Start in an 80x24 terminal.
2. Use gdb to start nano.
3. Inside gdb, set a breakpoint on reset_cursor(), and then run nano with "--ignore --softwrap reset_cursor-current_y-test.txt". (The file is attached.)
4. The first time reset_cursor() is called will trigger in gdb. This call is actually from a side effect: when the file is first being read in via display_buffer(), load_buffer() calls titlebar(NULL) to display the filename, and titlebar() calls reset_cursor(). However, the buffer is not in a valid state at this point: current is identical to fileage, and edittop is identical to filebot.
5. Trace through reset_cursor() via gdb. There's another problem as well, if you do this again without using --softwrap: since non-softwrap mode uses (current->lineno - edittop->lineno) to get the line number, current_y ends up being -1, but since softwrap mode adds the screen line count from edittop to current[current_x] and goes until it reaches NULL, current_y ends up being 4, which is erroneously in range.
|