]> granicus.if.org Git - vim/commitdiff
patch 7.4.975 v7.4.975
authorBram Moolenaar <Bram@vim.org>
Thu, 17 Dec 2015 14:07:32 +0000 (15:07 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 17 Dec 2015 14:07:32 +0000 (15:07 +0100)
Problem:    Using ":sort" on a very big file sometimes causes text to be
            corrupted. (John Beckett)
Solution:   Copy the line into a buffer before calling ml_append().

src/ex_cmds.c
src/version.c

index c2b600c5b65a5dd8aaa62cb5638458f200b4d0d8..05d4721d627cbd93aa9f32179b2de3781a1493b3 100644 (file)
@@ -540,10 +540,11 @@ ex_sort(eap)
        if (!unique || i == 0
                || (sort_ic ? STRICMP(s, sortbuf1) : STRCMP(s, sortbuf1)) != 0)
        {
-           if (ml_append(lnum++, s, (colnr_T)0, FALSE) == FAIL)
+           /* Copy the line into a buffer, it may become invalid in
+            * ml_append(). And it's needed for "unique". */
+           STRCPY(sortbuf1, s);
+           if (ml_append(lnum++, sortbuf1, (colnr_T)0, FALSE) == FAIL)
                break;
-           if (unique)
-               STRCPY(sortbuf1, s);
        }
        fast_breakcheck();
        if (got_int)
index 899e27f4936eed4f51ab0d3cf58c54e213001687..f7a4a20454c8c9fc996770e96c5cabd5013735b8 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    975,
 /**/
     974,
 /**/