comparison src/ex_docmd.c @ 26420:75e6d917696e v8.2.3741

patch 8.2.3741: using freed memory in open command Commit: https://github.com/vim/vim/commit/e031fe90cf2e375ce861ff5e5e281e4ad229ebb9 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 5 12:06:24 2021 +0000 patch 8.2.3741: using freed memory in open command Problem: Using freed memory in open command. Solution: Make a copy of the current line.
author Bram Moolenaar <Bram@vim.org>
date Sun, 05 Dec 2021 13:15:02 +0100
parents a3a0885d9dd8
children b18f3b0f317c
comparison
equal deleted inserted replaced
26419:63949665868b 26420:75e6d917696e
6875 p = skip_regexp(eap->arg, '/', magic_isset()); 6875 p = skip_regexp(eap->arg, '/', magic_isset());
6876 *p = NUL; 6876 *p = NUL;
6877 regmatch.regprog = vim_regcomp(eap->arg, magic_isset() ? RE_MAGIC : 0); 6877 regmatch.regprog = vim_regcomp(eap->arg, magic_isset() ? RE_MAGIC : 0);
6878 if (regmatch.regprog != NULL) 6878 if (regmatch.regprog != NULL)
6879 { 6879 {
6880 // make a copy of the line, when searching for a mark it might be
6881 // flushed
6882 char_u *line = vim_strsave(ml_get_curline());
6883
6880 regmatch.rm_ic = p_ic; 6884 regmatch.rm_ic = p_ic;
6881 p = ml_get_curline(); 6885 if (vim_regexec(&regmatch, line, (colnr_T)0))
6882 if (vim_regexec(&regmatch, p, (colnr_T)0)) 6886 curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - line);
6883 curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p);
6884 else 6887 else
6885 emsg(_(e_nomatch)); 6888 emsg(_(e_nomatch));
6886 vim_regfree(regmatch.regprog); 6889 vim_regfree(regmatch.regprog);
6890 vim_free(line);
6887 } 6891 }
6888 // Move to the NUL, ignore any other arguments. 6892 // Move to the NUL, ignore any other arguments.
6889 eap->arg += STRLEN(eap->arg); 6893 eap->arg += STRLEN(eap->arg);
6890 } 6894 }
6891 check_cursor(); 6895 check_cursor();