forked from aniani/vim
patch 9.1.0638: E1510 may happen when formatting a message for smsg()
Problem: E1510 may happen when formatting a message (after 9.1.0181). Solution: Only give E1510 when using typval. (zeertzjq) closes: #15391 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
81a65000c5
commit
0dff31576a
@@ -2497,7 +2497,8 @@ format_overflow_error(const char *pstart)
|
|||||||
get_unsigned_int(
|
get_unsigned_int(
|
||||||
const char *pstart,
|
const char *pstart,
|
||||||
const char **p,
|
const char **p,
|
||||||
unsigned int *uj)
|
unsigned int *uj,
|
||||||
|
int overflow_err)
|
||||||
{
|
{
|
||||||
*uj = **p - '0';
|
*uj = **p - '0';
|
||||||
++*p;
|
++*p;
|
||||||
@@ -2510,8 +2511,13 @@ get_unsigned_int(
|
|||||||
|
|
||||||
if (*uj > MAX_ALLOWED_STRING_WIDTH)
|
if (*uj > MAX_ALLOWED_STRING_WIDTH)
|
||||||
{
|
{
|
||||||
format_overflow_error(pstart);
|
if (overflow_err)
|
||||||
return FAIL;
|
{
|
||||||
|
format_overflow_error(pstart);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*uj = MAX_ALLOWED_STRING_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -2584,7 +2590,7 @@ parse_fmt_types(
|
|||||||
// Positional argument
|
// Positional argument
|
||||||
unsigned int uj;
|
unsigned int uj;
|
||||||
|
|
||||||
if (get_unsigned_int(pstart, &p, &uj) == FAIL)
|
if (get_unsigned_int(pstart, &p, &uj, tvs != NULL) == FAIL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
pos_arg = uj;
|
pos_arg = uj;
|
||||||
@@ -2625,7 +2631,7 @@ parse_fmt_types(
|
|||||||
// Positional argument field width
|
// Positional argument field width
|
||||||
unsigned int uj;
|
unsigned int uj;
|
||||||
|
|
||||||
if (get_unsigned_int(arg + 1, &p, &uj) == FAIL)
|
if (get_unsigned_int(arg + 1, &p, &uj, tvs != NULL) == FAIL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (*p != '$')
|
if (*p != '$')
|
||||||
@@ -2656,7 +2662,7 @@ parse_fmt_types(
|
|||||||
const char *digstart = p;
|
const char *digstart = p;
|
||||||
unsigned int uj;
|
unsigned int uj;
|
||||||
|
|
||||||
if (get_unsigned_int(digstart, &p, &uj) == FAIL)
|
if (get_unsigned_int(digstart, &p, &uj, tvs != NULL) == FAIL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (*p == '$')
|
if (*p == '$')
|
||||||
@@ -2680,7 +2686,7 @@ parse_fmt_types(
|
|||||||
// Parse precision
|
// Parse precision
|
||||||
unsigned int uj;
|
unsigned int uj;
|
||||||
|
|
||||||
if (get_unsigned_int(arg + 1, &p, &uj) == FAIL)
|
if (get_unsigned_int(arg + 1, &p, &uj, tvs != NULL) == FAIL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (*p == '$')
|
if (*p == '$')
|
||||||
@@ -2712,7 +2718,7 @@ parse_fmt_types(
|
|||||||
const char *digstart = p;
|
const char *digstart = p;
|
||||||
unsigned int uj;
|
unsigned int uj;
|
||||||
|
|
||||||
if (get_unsigned_int(digstart, &p, &uj) == FAIL)
|
if (get_unsigned_int(digstart, &p, &uj, tvs != NULL) == FAIL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (*p == '$')
|
if (*p == '$')
|
||||||
@@ -3025,7 +3031,7 @@ vim_vsnprintf_typval(
|
|||||||
const char *digstart = p;
|
const char *digstart = p;
|
||||||
unsigned int uj;
|
unsigned int uj;
|
||||||
|
|
||||||
if (get_unsigned_int(digstart, &p, &uj) == FAIL)
|
if (get_unsigned_int(digstart, &p, &uj, tvs != NULL) == FAIL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
pos_arg = uj;
|
pos_arg = uj;
|
||||||
@@ -3067,7 +3073,7 @@ vim_vsnprintf_typval(
|
|||||||
// Positional argument field width
|
// Positional argument field width
|
||||||
unsigned int uj;
|
unsigned int uj;
|
||||||
|
|
||||||
if (get_unsigned_int(digstart, &p, &uj) == FAIL)
|
if (get_unsigned_int(digstart, &p, &uj, tvs != NULL) == FAIL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
arg_idx = uj;
|
arg_idx = uj;
|
||||||
@@ -3085,8 +3091,13 @@ vim_vsnprintf_typval(
|
|||||||
|
|
||||||
if (j > MAX_ALLOWED_STRING_WIDTH)
|
if (j > MAX_ALLOWED_STRING_WIDTH)
|
||||||
{
|
{
|
||||||
format_overflow_error(digstart);
|
if (tvs != NULL)
|
||||||
goto error;
|
{
|
||||||
|
format_overflow_error(digstart);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
j = MAX_ALLOWED_STRING_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j >= 0)
|
if (j >= 0)
|
||||||
@@ -3104,15 +3115,9 @@ vim_vsnprintf_typval(
|
|||||||
const char *digstart = p;
|
const char *digstart = p;
|
||||||
unsigned int uj;
|
unsigned int uj;
|
||||||
|
|
||||||
if (get_unsigned_int(digstart, &p, &uj) == FAIL)
|
if (get_unsigned_int(digstart, &p, &uj, tvs != NULL) == FAIL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (uj > MAX_ALLOWED_STRING_WIDTH)
|
|
||||||
{
|
|
||||||
format_overflow_error(digstart);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
min_field_width = uj;
|
min_field_width = uj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3129,15 +3134,9 @@ vim_vsnprintf_typval(
|
|||||||
const char *digstart = p;
|
const char *digstart = p;
|
||||||
unsigned int uj;
|
unsigned int uj;
|
||||||
|
|
||||||
if (get_unsigned_int(digstart, &p, &uj) == FAIL)
|
if (get_unsigned_int(digstart, &p, &uj, tvs != NULL) == FAIL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (uj > MAX_ALLOWED_STRING_WIDTH)
|
|
||||||
{
|
|
||||||
format_overflow_error(digstart);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
precision = uj;
|
precision = uj;
|
||||||
}
|
}
|
||||||
else if (*p == '*')
|
else if (*p == '*')
|
||||||
@@ -3152,7 +3151,7 @@ vim_vsnprintf_typval(
|
|||||||
// positional argument
|
// positional argument
|
||||||
unsigned int uj;
|
unsigned int uj;
|
||||||
|
|
||||||
if (get_unsigned_int(digstart, &p, &uj) == FAIL)
|
if (get_unsigned_int(digstart, &p, &uj, tvs != NULL) == FAIL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
arg_idx = uj;
|
arg_idx = uj;
|
||||||
@@ -3170,8 +3169,13 @@ vim_vsnprintf_typval(
|
|||||||
|
|
||||||
if (j > MAX_ALLOWED_STRING_WIDTH)
|
if (j > MAX_ALLOWED_STRING_WIDTH)
|
||||||
{
|
{
|
||||||
format_overflow_error(digstart);
|
if (tvs != NULL)
|
||||||
goto error;
|
{
|
||||||
|
format_overflow_error(digstart);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
j = MAX_ALLOWED_STRING_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j >= 0)
|
if (j >= 0)
|
||||||
|
@@ -845,6 +845,22 @@ func Test_spell_add_word()
|
|||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_spell_add_long_word()
|
||||||
|
set spell spellfile=./Xspellfile.add spelllang=en
|
||||||
|
|
||||||
|
let word = repeat('a', 9000)
|
||||||
|
let v:errmsg = ''
|
||||||
|
" Spell checking doesn't really work for such a long word,
|
||||||
|
" but this should not cause an E1510 error.
|
||||||
|
exe 'spellgood ' .. word
|
||||||
|
call assert_equal('', v:errmsg)
|
||||||
|
call assert_equal([word], readfile('./Xspellfile.add'))
|
||||||
|
|
||||||
|
set spell& spellfile= spelllang& encoding=utf-8
|
||||||
|
call delete('./Xspellfile.add')
|
||||||
|
call delete('./Xspellfile.add.spl')
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_spellfile_verbose()
|
func Test_spellfile_verbose()
|
||||||
call writefile(['1', 'one'], 'XtestVerbose.dic', 'D')
|
call writefile(['1', 'one'], 'XtestVerbose.dic', 'D')
|
||||||
call writefile([], 'XtestVerbose.aff', 'D')
|
call writefile([], 'XtestVerbose.aff', 'D')
|
||||||
|
@@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
638,
|
||||||
/**/
|
/**/
|
||||||
637,
|
637,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user