Mercurial > vim
comparison src/vim9cmds.c @ 29742:2da1753e6a4a v9.0.0211
patch 9.0.0211: invalid memory access when compiling :lockvar
Commit: https://github.com/vim/vim/commit/d1d8f6bacb489036d0fd479c9dd3c0102c988889
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 14 21:28:32 2022 +0100
patch 9.0.0211: invalid memory access when compiling :lockvar
Problem: Invalid memory access when compiling :lockvar.
Solution: Don't read past the end of the line.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 14 Aug 2022 22:30:02 +0200 |
parents | d550054e1328 |
children | 1e9ee1b61d6d |
comparison
equal
deleted
inserted
replaced
29741:71f1aa981b8e | 29742:2da1753e6a4a |
---|---|
186 char_u *p = lvp->ll_name; | 186 char_u *p = lvp->ll_name; |
187 int ret = OK; | 187 int ret = OK; |
188 size_t len; | 188 size_t len; |
189 char_u *buf; | 189 char_u *buf; |
190 isntype_T isn = ISN_EXEC; | 190 isntype_T isn = ISN_EXEC; |
191 char *cmd = eap->cmdidx == CMD_lockvar ? "lockvar" : "unlockvar"; | |
191 | 192 |
192 if (cctx->ctx_skip == SKIP_YES) | 193 if (cctx->ctx_skip == SKIP_YES) |
193 return OK; | 194 return OK; |
195 | |
196 if (*p == NUL) | |
197 { | |
198 semsg(_(e_argument_required_for_str), cmd); | |
199 return FAIL; | |
200 } | |
194 | 201 |
195 // Cannot use :lockvar and :unlockvar on local variables. | 202 // Cannot use :lockvar and :unlockvar on local variables. |
196 if (p[1] != ':') | 203 if (p[1] != ':') |
197 { | 204 { |
198 char_u *end = find_name_end(p, NULL, NULL, FNE_CHECK_START); | 205 char_u *end = find_name_end(p, NULL, NULL, FNE_CHECK_START); |
221 buf = alloc(len); | 228 buf = alloc(len); |
222 if (buf == NULL) | 229 if (buf == NULL) |
223 ret = FAIL; | 230 ret = FAIL; |
224 else | 231 else |
225 { | 232 { |
226 char *cmd = eap->cmdidx == CMD_lockvar ? "lockvar" : "unlockvar"; | |
227 | |
228 if (deep < 0) | 233 if (deep < 0) |
229 vim_snprintf((char *)buf, len, "%s! %s", cmd, p); | 234 vim_snprintf((char *)buf, len, "%s! %s", cmd, p); |
230 else | 235 else |
231 vim_snprintf((char *)buf, len, "%s %d %s", cmd, deep, p); | 236 vim_snprintf((char *)buf, len, "%s %d %s", cmd, deep, p); |
232 ret = generate_EXEC_copy(cctx, isn, buf); | 237 ret = generate_EXEC_copy(cctx, isn, buf); |