comparison src/memline.c @ 10896:d513b653f5d0 v8.0.0337

patch 8.0.0337: invalid memory access in :recover command commit https://github.com/vim/vim/commit/c525e3a1c20f6b5d9809c8b84f80090a8e416c92 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 18 16:59:02 2017 +0100 patch 8.0.0337: invalid memory access in :recover command Problem: Invalid memory access in :recover command. Solution: Avoid access before directory name. (Dominique Pelle, closes #1488)
author Christian Brabandt <cb@256bit.org>
date Sat, 18 Feb 2017 17:00:05 +0100
parents 5780bd3a5a7e
children 835604f3c37a
comparison
equal deleted inserted replaced
10895:c391bfbdb452 10896:d513b653f5d0
1861 #endif 1861 #endif
1862 } 1862 }
1863 else 1863 else
1864 { 1864 {
1865 #if defined(UNIX) || defined(WIN3264) 1865 #if defined(UNIX) || defined(WIN3264)
1866 p = dir_name + STRLEN(dir_name); 1866 int len = STRLEN(dir_name);
1867 if (after_pathsep(dir_name, p) && p[-1] == p[-2]) 1867
1868 p = dir_name + len;
1869 if (after_pathsep(dir_name, p) && len > 1 && p[-1] == p[-2])
1868 { 1870 {
1869 /* Ends with '//', Use Full path for swap name */ 1871 /* Ends with '//', Use Full path for swap name */
1870 tail = make_percent_swname(dir_name, fname_res); 1872 tail = make_percent_swname(dir_name, fname_res);
1871 } 1873 }
1872 else 1874 else
3920 #ifdef HAVE_READLINK 3922 #ifdef HAVE_READLINK
3921 char_u fname_buf[MAXPATHL]; 3923 char_u fname_buf[MAXPATHL];
3922 #endif 3924 #endif
3923 3925
3924 #if defined(UNIX) || defined(WIN3264) /* Need _very_ long file names */ 3926 #if defined(UNIX) || defined(WIN3264) /* Need _very_ long file names */
3925 s = dir_name + STRLEN(dir_name); 3927 int len = STRLEN(dir_name);
3926 if (after_pathsep(dir_name, s) && s[-1] == s[-2]) 3928
3929 s = dir_name + len;
3930 if (after_pathsep(dir_name, s) && len > 1 && s[-1] == s[-2])
3927 { /* Ends with '//', Use Full path */ 3931 { /* Ends with '//', Use Full path */
3928 r = NULL; 3932 r = NULL;
3929 if ((s = make_percent_swname(dir_name, fname)) != NULL) 3933 if ((s = make_percent_swname(dir_name, fname)) != NULL)
3930 { 3934 {
3931 r = modname(s, (char_u *)".swp", FALSE); 3935 r = modname(s, (char_u *)".swp", FALSE);