comparison src/userfunc.c @ 22496:454b78ca8247 v8.2.1796

patch 8.2.1796: Vim9: invalid memory access with weird function name Commit: https://github.com/vim/vim/commit/7b5d5442696d86daab062592d5c86c829757c352 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 4 13:42:34 2020 +0200 patch 8.2.1796: Vim9: invalid memory access with weird function name Problem: Vim9: invalid memory access with weird function name. (Dhiraj Mishra) Solution: Check the name is valid. Add a test.
author Bram Moolenaar <Bram@vim.org>
date Sun, 04 Oct 2020 13:45:04 +0200
parents 1cefe1c013ac
children 107eae953b87
comparison
equal deleted inserted replaced
22495:f54613c0687b 22496:454b78ca8247
2372 char_u sid_buf[20]; 2372 char_u sid_buf[20];
2373 int len; 2373 int len;
2374 int extra = 0; 2374 int extra = 0;
2375 lval_T lv; 2375 lval_T lv;
2376 int vim9script; 2376 int vim9script;
2377 static char *e_function_name = N_("E129: Function name required");
2377 2378
2378 if (fdp != NULL) 2379 if (fdp != NULL)
2379 CLEAR_POINTER(fdp); 2380 CLEAR_POINTER(fdp);
2380 start = *pp; 2381 start = *pp;
2381 2382
2399 end = get_lval(start, NULL, &lv, FALSE, skip, flags | GLV_READ_ONLY, 2400 end = get_lval(start, NULL, &lv, FALSE, skip, flags | GLV_READ_ONLY,
2400 lead > 2 ? 0 : FNE_CHECK_START); 2401 lead > 2 ? 0 : FNE_CHECK_START);
2401 if (end == start) 2402 if (end == start)
2402 { 2403 {
2403 if (!skip) 2404 if (!skip)
2404 emsg(_("E129: Function name required")); 2405 emsg(_(e_function_name));
2405 goto theend; 2406 goto theend;
2406 } 2407 }
2407 if (end == NULL || (lv.ll_tv != NULL && (lead > 2 || lv.ll_range))) 2408 if (end == NULL || (lv.ll_tv != NULL && (lead > 2 || lv.ll_range)))
2408 { 2409 {
2409 /* 2410 /*
2514 if (is_global != NULL && lv.ll_name[0] == 'g') 2515 if (is_global != NULL && lv.ll_name[0] == 'g')
2515 *is_global = TRUE; 2516 *is_global = TRUE;
2516 lv.ll_name += 2; 2517 lv.ll_name += 2;
2517 } 2518 }
2518 len = (int)(end - lv.ll_name); 2519 len = (int)(end - lv.ll_name);
2520 }
2521 if (len <= 0)
2522 {
2523 if (!skip)
2524 emsg(_(e_function_name));
2525 goto theend;
2519 } 2526 }
2520 2527
2521 // In Vim9 script a user function is script-local by default. 2528 // In Vim9 script a user function is script-local by default.
2522 vim9script = ASCII_ISUPPER(*start) && in_vim9script(); 2529 vim9script = ASCII_ISUPPER(*start) && in_vim9script();
2523 2530