Mercurial > vim
comparison src/evalfunc.c @ 26585:0d2a709e2ff0 v8.2.3822
patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9
Commit: https://github.com/vim/vim/commit/2d877599ee1cede063ef4abe3a2272e67c116238
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Dec 16 08:21:09 2021 +0000
patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9
Problem: Leaking memory in map() and filter(), cannot use a string argument
in Vim9 script.
Solution: Fix the leak, adjust the argument check, also run the tests as
Vim9 script. (Yegappan Lakshmanan, closes #9354)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 16 Dec 2021 09:30:04 +0100 |
parents | 255bc9a08e58 |
children | fac6673086df |
comparison
equal
deleted
inserted
replaced
26584:b1299fc6445b | 26585:0d2a709e2ff0 |
---|---|
441 { | 441 { |
442 if (type->tt_type == VAR_ANY | 442 if (type->tt_type == VAR_ANY |
443 || type->tt_type == VAR_LIST | 443 || type->tt_type == VAR_LIST |
444 || type->tt_type == VAR_DICT | 444 || type->tt_type == VAR_DICT |
445 || type->tt_type == VAR_BLOB) | 445 || type->tt_type == VAR_BLOB) |
446 return OK; | |
447 arg_type_mismatch(&t_list_any, type, context->arg_idx + 1); | |
448 return FAIL; | |
449 } | |
450 | |
451 /* | |
452 * Check "type" is a list of 'any' or a dict of 'any' or a blob or a string. | |
453 */ | |
454 static int | |
455 arg_list_or_dict_or_blob_or_string(type_T *type, argcontext_T *context) | |
456 { | |
457 if (type->tt_type == VAR_ANY | |
458 || type->tt_type == VAR_LIST | |
459 || type->tt_type == VAR_DICT | |
460 || type->tt_type == VAR_BLOB | |
461 || type->tt_type == VAR_STRING) | |
446 return OK; | 462 return OK; |
447 arg_type_mismatch(&t_list_any, type, context->arg_idx + 1); | 463 arg_type_mismatch(&t_list_any, type, context->arg_idx + 1); |
448 return FAIL; | 464 return FAIL; |
449 } | 465 } |
450 | 466 |
795 static argcheck_T arg24_index[] = {arg_list_or_blob, arg_item_of_prev, arg_number, arg_bool}; | 811 static argcheck_T arg24_index[] = {arg_list_or_blob, arg_item_of_prev, arg_number, arg_bool}; |
796 static argcheck_T arg23_insert[] = {arg_list_or_blob, arg_item_of_prev, arg_number}; | 812 static argcheck_T arg23_insert[] = {arg_list_or_blob, arg_item_of_prev, arg_number}; |
797 static argcheck_T arg1_len[] = {arg_len1}; | 813 static argcheck_T arg1_len[] = {arg_len1}; |
798 static argcheck_T arg3_libcall[] = {arg_string, arg_string, arg_string_or_nr}; | 814 static argcheck_T arg3_libcall[] = {arg_string, arg_string, arg_string_or_nr}; |
799 static argcheck_T arg14_maparg[] = {arg_string, arg_string, arg_bool, arg_bool}; | 815 static argcheck_T arg14_maparg[] = {arg_string, arg_string, arg_bool, arg_bool}; |
800 static argcheck_T arg2_mapfilter[] = {arg_list_or_dict_or_blob, NULL}; | 816 static argcheck_T arg2_mapfilter[] = {arg_list_or_dict_or_blob_or_string, NULL}; |
801 static argcheck_T arg25_matchadd[] = {arg_string, arg_string, arg_number, arg_number, arg_dict_any}; | 817 static argcheck_T arg25_matchadd[] = {arg_string, arg_string, arg_number, arg_number, arg_dict_any}; |
802 static argcheck_T arg25_matchaddpos[] = {arg_string, arg_list_any, arg_number, arg_number, arg_dict_any}; | 818 static argcheck_T arg25_matchaddpos[] = {arg_string, arg_list_any, arg_number, arg_number, arg_dict_any}; |
803 static argcheck_T arg119_printf[] = {arg_string_or_nr, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; | 819 static argcheck_T arg119_printf[] = {arg_string_or_nr, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; |
804 static argcheck_T arg23_reduce[] = {arg_list_or_blob, NULL, NULL}; | 820 static argcheck_T arg23_reduce[] = {arg_list_or_blob, NULL, NULL}; |
805 static argcheck_T arg24_remote_expr[] = {arg_string, arg_string, arg_string, arg_number}; | 821 static argcheck_T arg24_remote_expr[] = {arg_string, arg_string, arg_string, arg_number}; |