Mercurial > vim
comparison src/userfunc.c @ 17883:6249953b0609 v8.1.1938
patch 8.1.1938: may crash when out of memory
Commit: https://github.com/vim/vim/commit/c507a2d164cfa3dcf31a7ba9dad6663a17243bb4
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 29 21:32:55 2019 +0200
patch 8.1.1938: may crash when out of memory
Problem: May crash when out of memory.
Solution: Initialize v_type to VAR_UNKNOWN. (Dominique Pelle, closes https://github.com/vim/vim/issues/4871)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 29 Aug 2019 21:45:04 +0200 |
parents | 59f8948b7590 |
children | e59ff7b5d7a7 |
comparison
equal
deleted
inserted
replaced
17882:f7890929f547 | 17883:6249953b0609 |
---|---|
1499 // "funcexe->basetv" is not NULL | 1499 // "funcexe->basetv" is not NULL |
1500 int argv_clear = 0; | 1500 int argv_clear = 0; |
1501 int argv_base = 0; | 1501 int argv_base = 0; |
1502 partial_T *partial = funcexe->partial; | 1502 partial_T *partial = funcexe->partial; |
1503 | 1503 |
1504 // Initialize rettv so that it is safe for caller to invoke clear_tv(rettv) | |
1505 // even when call_func() returns FAIL. | |
1506 rettv->v_type = VAR_UNKNOWN; | |
1507 | |
1504 // Make a copy of the name, if it comes from a funcref variable it could | 1508 // Make a copy of the name, if it comes from a funcref variable it could |
1505 // be changed or deleted in the called function. | 1509 // be changed or deleted in the called function. |
1506 name = len > 0 ? vim_strnsave(funcname, len) : vim_strsave(funcname); | 1510 name = len > 0 ? vim_strnsave(funcname, len) : vim_strsave(funcname); |
1507 if (name == NULL) | 1511 if (name == NULL) |
1508 return ret; | 1512 return ret; |
1528 argvars = argv; | 1532 argvars = argv; |
1529 argcount = partial->pt_argc + argcount_in; | 1533 argcount = partial->pt_argc + argcount_in; |
1530 } | 1534 } |
1531 } | 1535 } |
1532 | 1536 |
1533 /* | 1537 if (error == ERROR_NONE && funcexe->evaluate) |
1534 * Execute the function if executing and no errors were detected. | |
1535 */ | |
1536 if (!funcexe->evaluate) | |
1537 { | |
1538 // Not evaluating, which means the return value is unknown. This | |
1539 // matters for giving error messages. | |
1540 rettv->v_type = VAR_UNKNOWN; | |
1541 } | |
1542 else if (error == ERROR_NONE) | |
1543 { | 1538 { |
1544 char_u *rfname = fname; | 1539 char_u *rfname = fname; |
1545 | 1540 |
1546 /* Ignore "g:" before a function name. */ | 1541 /* Ignore "g:" before a function name. */ |
1547 if (fname[0] == 'g' && fname[1] == ':') | 1542 if (fname[0] == 'g' && fname[1] == ':') |