nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit ec3cd1eeae3506d7d55241c59895841d3130ef33
parent 813f9f72d0669ba882c3adb38ba24873e9e32b68
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Sat, 13 Feb 2016 17:00:06 +0000

Allocating enough space for printing out the line and column numbers.
This fixes Savannah bug #47135.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5639 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

Diffstat:
MChangeLog | 2++
Msrc/files.c | 4+++-
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog @@ -2,6 +2,8 @@ * src/browser.c (do_browser, browser_refresh): Rebuild the file list only when necessary, not for each and every cursor movement. This fixes Savannah bug #47133. + * src/files.c (save_poshistory): Allocate enough space for printing + out the line and column numbers. This fixes Savannah bug #47135. GNU nano 2.5.2 - 2016.02.12 diff --git a/src/files.c b/src/files.c @@ -3177,7 +3177,9 @@ void save_poshistory(void) chmod(poshist, S_IRUSR | S_IWUSR); for (posptr = position_history; posptr != NULL; posptr = posptr->next) { - statusstr = charalloc(strlen(posptr->filename) + 2 * sizeof(ssize_t) + 4); + /* Assume 20 decimal positions each for line and column number, + * plus two spaces, plus the line feed, plus the null byte. */ + statusstr = charalloc(strlen(posptr->filename) + 44); sprintf(statusstr, "%s %ld %ld\n", posptr->filename, (long)posptr->lineno, (long)posptr->xno); if (fwrite(statusstr, sizeof(char), strlen(statusstr), hist) < strlen(statusstr))