Mercurial > vim
comparison src/vim9execute.c @ 22612:b08f435d5b86 v8.2.1854
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Commit: https://github.com/vim/vim/commit/1e021e63c565bbb30783a557b4e883cc27f56403
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Oct 16 20:25:23 2020 +0200
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Problem: Vim9: crash when throwing exception for NULL string. (Dhiraj
Mishra)
Solution: Handle NULL string like empty string. (closes #7139)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 16 Oct 2020 20:30:04 +0200 |
parents | 107eae953b87 |
children | 048a3033d19c |
comparison
equal
deleted
inserted
replaced
22611:377667e0a347 | 22612:b08f435d5b86 |
---|---|
1379 if (GA_GROW(&ectx.ec_stack, 1) == FAIL) | 1379 if (GA_GROW(&ectx.ec_stack, 1) == FAIL) |
1380 goto failed; | 1380 goto failed; |
1381 tv = STACK_TV_BOT(0); | 1381 tv = STACK_TV_BOT(0); |
1382 tv->v_type = VAR_STRING; | 1382 tv->v_type = VAR_STRING; |
1383 tv->v_lock = 0; | 1383 tv->v_lock = 0; |
1384 // This may result in NULL, which should be equivalent to an | |
1385 // empty string. | |
1384 tv->vval.v_string = get_reg_contents( | 1386 tv->vval.v_string = get_reg_contents( |
1385 iptr->isn_arg.number, GREG_EXPR_SRC); | 1387 iptr->isn_arg.number, GREG_EXPR_SRC); |
1386 ++ectx.ec_stack.ga_len; | 1388 ++ectx.ec_stack.ga_len; |
1387 break; | 1389 break; |
1388 | 1390 |
2080 break; | 2082 break; |
2081 | 2083 |
2082 case ISN_THROW: | 2084 case ISN_THROW: |
2083 --ectx.ec_stack.ga_len; | 2085 --ectx.ec_stack.ga_len; |
2084 tv = STACK_TV_BOT(0); | 2086 tv = STACK_TV_BOT(0); |
2087 if (tv->vval.v_string == NULL | |
2088 || *skipwhite(tv->vval.v_string) == NUL) | |
2089 { | |
2090 emsg(_(e_throw_with_empty_string)); | |
2091 goto failed; | |
2092 } | |
2093 | |
2085 if (throw_exception(tv->vval.v_string, ET_USER, NULL) == FAIL) | 2094 if (throw_exception(tv->vval.v_string, ET_USER, NULL) == FAIL) |
2086 { | 2095 { |
2087 vim_free(tv->vval.v_string); | 2096 vim_free(tv->vval.v_string); |
2088 goto failed; | 2097 goto failed; |
2089 } | 2098 } |