vim-patch:9.1.0913: no error check for neg values for 'messagesopt' (#31511)

Problem:  no error check for neg values for 'messagesopt'
          (after v9.1.0908)
Solution: add additional error checks and tests (h-east)

closes: vim/vim#16187

65be834c30

Nvim's getdigits() checks for overflow, so the code change isn't needed.

Co-authored-by: h-east <h.east.727@gmail.com>
This commit is contained in:
zeertzjq 2024-12-08 17:53:01 +08:00 committed by GitHub
parent fe1e2eff06
commit ca4f688ad4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -1098,11 +1098,13 @@ int messagesopt_changed(void)
return FAIL; return FAIL;
} }
assert(messages_history_new >= 0);
// "history" must be <= 10000 // "history" must be <= 10000
if (messages_history_new > 10000) { if (messages_history_new > 10000) {
return FAIL; return FAIL;
} }
assert(messages_wait_new >= 0);
// "wait" must be <= 10000 // "wait" must be <= 10000
if (messages_wait_new > 10000) { if (messages_wait_new > 10000) {
return FAIL; return FAIL;

View File

@ -268,7 +268,9 @@ let test_values = {
\ 'hit-enter,history:1,wait:1'], \ 'hit-enter,history:1,wait:1'],
\ ['xxx', 'history:500', 'hit-enter,history:-1', \ ['xxx', 'history:500', 'hit-enter,history:-1',
\ 'hit-enter,history:10001', 'history:0,wait:10001', \ 'hit-enter,history:10001', 'history:0,wait:10001',
\ 'hit-enter']], \ 'hit-enter', 'history:10,wait:99999999999999999999',
\ 'history:99999999999999999999,wait:10', 'wait:10',
\ 'history:-10', 'history:10,wait:-10']],
\ 'mkspellmem': [['10000,100,12'], ['', 'xxx', '10000,100']], \ 'mkspellmem': [['10000,100,12'], ['', 'xxx', '10000,100']],
\ 'mouse': [['', 'n', 'v', 'i', 'c', 'h', 'a', 'r', 'nvi'], \ 'mouse': [['', 'n', 'v', 'i', 'c', 'h', 'a', 'r', 'nvi'],
\ ['xxx', 'n,v,i']], \ ['xxx', 'n,v,i']],