mirror of
https://github.com/neovim/neovim.git
synced 2025-10-09 03:16:31 +00:00
vim-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 vim/vim#1488)
c525e3a1c2
This commit is contained in:
@@ -1330,9 +1330,12 @@ recover_names (
|
||||
names[2] = (char_u *)concat_fnames((char *)dir_name, ".sw?", TRUE);
|
||||
num_names = 3;
|
||||
} else {
|
||||
p = dir_name + STRLEN(dir_name);
|
||||
if (after_pathsep((char *)dir_name, (char *)p) && p[-1] == p[-2]) {
|
||||
/* Ends with '//', Use Full path for swap name */
|
||||
int len = STRLEN(dir_name);
|
||||
p = dir_name + len;
|
||||
if (after_pathsep((char *)dir_name, (char *)p)
|
||||
&& len > 1
|
||||
&& p[-1] == p[-2]) {
|
||||
// Ends with '//', Use Full path for swap name
|
||||
tail = (char_u *)make_percent_swname((char *)dir_name, (char *)fname_res);
|
||||
} else {
|
||||
tail = path_tail(fname_res);
|
||||
@@ -3054,9 +3057,12 @@ char_u *makeswapname(char_u *fname, char_u *ffname, buf_T *buf, char_u *dir_name
|
||||
#ifdef HAVE_READLINK
|
||||
char_u fname_buf[MAXPATHL];
|
||||
#endif
|
||||
int len = STRLEN(dir_name);
|
||||
|
||||
s = dir_name + STRLEN(dir_name);
|
||||
if (after_pathsep((char *)dir_name, (char *)s) && s[-1] == s[-2]) { /* Ends with '//', Use Full path */
|
||||
s = dir_name + len;
|
||||
if (after_pathsep((char *)dir_name, (char *)s)
|
||||
&& len > 1
|
||||
&& s[-1] == s[-2]) { // Ends with '//', Use Full path
|
||||
r = NULL;
|
||||
if ((s = (char_u *)make_percent_swname((char *)dir_name, (char *)fname)) != NULL) {
|
||||
r = (char_u *)modname((char *)s, ".swp", FALSE);
|
||||
|
Reference in New Issue
Block a user