diff options
author | Bram Moolenaar <Bram@vim.org> | 2015-12-17 15:07:32 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2015-12-17 15:07:32 +0100 |
commit | 75e3ad019933f4879137775549261bf51985ab7d (patch) | |
tree | a2801d543c4b0595957f818ce3d4d3cc2a845e85 /src/ex_cmds.c | |
parent | f29a82dcd0914c76f595d475ddac4517371fab2b (diff) | |
download | vim-git-75e3ad019933f4879137775549261bf51985ab7d.tar.gz |
patch 7.4.975v7.4.975
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().
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r-- | src/ex_cmds.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c index c2b600c5b..05d4721d6 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -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) |