]> git.wh0rd.org Git - nano.git/commitdiff
- cut.c: cut_marked_segment() - Fix off-by one in mem allocation
authorChris Allegretta <chrisa@asty.org>
Tue, 23 Oct 2001 13:21:20 +0000 (13:21 +0000)
committerChris Allegretta <chrisa@asty.org>
Tue, 23 Oct 2001 13:21:20 +0000 (13:21 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_1_0_branch/nano@869 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
cut.c

index 861c624f625cde20db4bbd123636fdb8d9cac8d6..65d6e5d5c953fdfc0d582094a53b5d48d2e9c887 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@ CVS code -
        - Fixed null_at to ACTUALLY DO SOMETHING with its arg.  Again,
          this was causing nasty errors if the call to nrealloc moved
          where the data was located.
+- cut.c:
+  cut_marked_segment()
+       - Fix off-by one in mem allocation.
 - po/de.po:
        - Updated German translation (Karl Eichwalder).
 
diff --git a/cut.c b/cut.c
index 7d1fd9921a280d729e66421d700ced328f49ddd5..3de8f7903bddbf8593aa34cef93fa4ea40df25d8 100644 (file)
--- a/cut.c
+++ b/cut.c
@@ -90,7 +90,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
     if (next == NULL)
        return;
     /* Now, paste bot[bot_x] into top[top_x] */
-    tmpstr = nmalloc(strlen(top->data) + strlen(&bot->data[bot_x]));
+    tmpstr = nmalloc(top_x + strlen(&bot->data[bot_x]) + 1);
     strncpy(tmpstr, top->data, top_x);
     strcpy(&tmpstr[top_x], &bot->data[bot_x]);
     free(top->data);