Skip to content

Commit

Permalink
patch 8.2.3411: Vim9: crash when using base name of import
Browse files Browse the repository at this point in the history
Problem:    Vim9: crash when using base name of import. (Naohiro Ono)
Solution:   Check the import flags. (closes vim#8843)
  • Loading branch information
brammool committed Sep 7, 2021
1 parent 89a54b4 commit 6853c38
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,3 +654,5 @@ EXTERN char e_legacy_must_be_followed_by_command[]
INIT(= N_("E1234: legacy must be followed by a command"));
EXTERN char e_function_reference_is_not_set[]
INIT(= N_("E1235: Function reference is not set"));
EXTERN char e_cannot_use_str_itself_it_is_imported_with_star[]
INIT(= N_("E1236: Cannot use %s itself, it is imported with '*'"));
6 changes: 6 additions & 0 deletions src/evalvars.c
Original file line number Diff line number Diff line change
Expand Up @@ -3260,6 +3260,12 @@ set_var_const(
semsg(_(e_redefining_imported_item_str), name);
goto failed;
}
if (import->imp_flags & IMP_FLAGS_STAR)
{
semsg(_(e_cannot_use_str_itself_it_is_imported_with_star),
name);
goto failed;
}
sv = ((svar_T *)si->sn_var_vals.ga_data) + import->imp_var_vals_idx;

where.wt_variable = TRUE;
Expand Down
15 changes: 15 additions & 0 deletions src/testdir/test_vim9_script.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,21 @@ def Test_vim9_import_export()
delete('Xvim9_script')
enddef

def Test_import_star_fails()
writefile([], 'Xfoo.vim')
var lines =<< trim END
import * as foo from '/tmp/foo.vim'
foo = 'bar'
END
CheckDefAndScriptFailure2(lines, 'E1094:', 'E1236: Cannot use foo itself')
lines =<< trim END
vim9script
import * as foo from '/tmp/foo.vim'
var that = foo
END
CheckScriptFailure(lines, 'E1029: Expected ''.''')
enddef

def Test_import_as()
var export_lines =<< trim END
vim9script
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3411,
/**/
3410,
/**/
Expand Down

0 comments on commit 6853c38

Please sign in to comment.