On Feb 18, 2008 8:59 AM, Patrick Texier <[EMAIL PROTECTED]> wrote:

> I'm using vim 7.1.252 (huge) on Linux (enc=tenc=latin1).
>
> When I call :sort with only one line in a buffer, the line is erased.
>
> vim -u NONE
>
> iOne line<ESC>
> :sort
>
> I get:
>
> ~<[EMAIL PROTECTED]

For me, the line completely disappears (which is not right either).
I'm using Vim 7.1.252 on Linux (huge, enc=fenc=utf8)

Valgrind memory checker sees a problem when sorting only 1 line:

==8855== Invalid read of size 1
==8855==    at 0x4C22F92: strlen (mc_replace_strmem.c:242)
==8855==    by 0x4B70BD: ml_append_int (memline.c:2235)
==8855==    by 0x4B6F9C: ml_append (memline.c:2179)
==8855==    by 0x44FEFB: ex_sort (ex_cmds.c:522)
==8855==    by 0x463CBE: do_one_cmd (ex_docmd.c:2623)
==8855==    by 0x4614BD: do_cmdline (ex_docmd.c:1099)
==8855==    by 0x4EBE41: nv_colon (normal.c:5179)
==8855==    by 0x4E4E47: normal_cmd (normal.c:1152)
==8855==    by 0x4A5C35: main_loop (main.c:1181)
==8855==    by 0x4A5781: main (main.c:940)
==8855==  Address 0xb9bb468 is 0 bytes inside a block of size 9 free'd
==8855==    at 0x4C21B6E: free (vg_replace_malloc.c:323)
==8855==    by 0x4D4E4A: vim_free (misc2.c:1580)
==8855==    by 0x4B8FA7: ml_flush_line (memline.c:3149)
==8855==    by 0x4B6F79: ml_append (memline.c:2178)
==8855==    by 0x44FEFB: ex_sort (ex_cmds.c:522)
==8855==    by 0x463CBE: do_one_cmd (ex_docmd.c:2623)
==8855==    by 0x4614BD: do_cmdline (ex_docmd.c:1099)
==8855==    by 0x4EBE41: nv_colon (normal.c:5179)
==8855==    by 0x4E4E47: normal_cmd (normal.c:1152)
==8855==    by 0x4A5C35: main_loop (main.c:1181)
==8855==    by 0x4A5781: main (main.c:940)

Attached is a patch which fixes it.

-- Dominique

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Index: ex_cmds.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/ex_cmds.c,v
retrieving revision 1.106
diff -c -r1.106 ex_cmds.c
*** ex_cmds.c	19 Jan 2008 14:59:58 -0000	1.106
--- ex_cmds.c	18 Feb 2008 08:31:14 -0000
***************
*** 365,370 ****
--- 365,372 ----
      int		sort_oct;		/* sort on octal number */
      int		sort_hex;		/* sort on hex number */
  
+     if (count <= 1)
+         return;
      if (u_save((linenr_T)(eap->line1 - 1), (linenr_T)(eap->line2 + 1)) == FAIL)
  	return;
      sortbuf1 = NULL;

Raspunde prin e-mail lui