- cut.c: cut_marked_segment() - Fix off-by one in mem allocation

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@868 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2001-10-23 12:58:42 +00:00
parent fa0c6963ce
commit e7ee63f271
2 changed files with 3 additions and 1 deletions

View File

@ -15,6 +15,8 @@ CVS code -
replaces cuttingpartialline). replaces cuttingpartialline).
do_uncut_text() do_uncut_text()
- Similar display fixes (David Lawrence Ramsey). - Similar display fixes (David Lawrence Ramsey).
cut_marked_segment()
- Fix off-by one in mem allocation.
- faq.html - faq.html
- Removed nano-editor.org FTP site address [deprecated] and added - Removed nano-editor.org FTP site address [deprecated] and added
the GNU one. the GNU one.

2
cut.c
View File

@ -141,7 +141,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
/* Now, paste bot[bot_x] into top[top_x] */ /* Now, paste bot[bot_x] into top[top_x] */
if (destructive) { if (destructive) {
tmpstr = charalloc(strlen(top->data) + strlen(&bot->data[bot_x])); tmpstr = charalloc(top_x + strlen(&bot->data[bot_x]) + 1);
strncpy(tmpstr, top->data, top_x); strncpy(tmpstr, top->data, top_x);
strcpy(&tmpstr[top_x], &bot->data[bot_x]); strcpy(&tmpstr[top_x], &bot->data[bot_x]);
free(top->data); free(top->data);