Skip to content

Commit 75e3ad0

Browse files
committed
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().
1 parent f29a82d commit 75e3ad0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/ex_cmds.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,11 @@ ex_sort(eap)
540540
if (!unique || i == 0
541541
|| (sort_ic ? STRICMP(s, sortbuf1) : STRCMP(s, sortbuf1)) != 0)
542542
{
543-
if (ml_append(lnum++, s, (colnr_T)0, FALSE) == FAIL)
543+
/* Copy the line into a buffer, it may become invalid in
544+
* ml_append(). And it's needed for "unique". */
545+
STRCPY(sortbuf1, s);
546+
if (ml_append(lnum++, sortbuf1, (colnr_T)0, FALSE) == FAIL)
544547
break;
545-
if (unique)
546-
STRCPY(sortbuf1, s);
547548
}
548549
fast_breakcheck();
549550
if (got_int)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
975,
744746
/**/
745747
974,
746748
/**/

0 commit comments

Comments
 (0)