0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 7.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().
This commit is contained in:
Bram Moolenaar
2015-12-17 15:07:32 +01:00
parent f29a82dcd0
commit 75e3ad0199
2 changed files with 6 additions and 3 deletions

View 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)