From: Benno Schulenberg Date: Sat, 13 Feb 2016 17:00:06 +0000 (+0000) Subject: Allocating enough space for printing out the line and column numbers. X-Git-Tag: v2.5.3~41 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=ec3cd1eeae3506d7d55241c59895841d3130ef33;p=nano.git 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 --- diff --git a/ChangeLog b/ChangeLog index 33213f28..87faafe6 100644 --- 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 index c16b9272..400f2a60 100644 --- 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))