mirror of
https://github.com/vim/vim.git
synced 2025-11-13 22:54:27 -05:00
patch 8.2.0892: ubsan warns for undefined behavior
Problem: Ubsan warns for undefined behavior.
Solution: Use unsigned instead of signed variable. (Dominique Pelle,
closes #6193)
This commit is contained in:
@@ -246,6 +246,7 @@ static int nfa_classcodes[] = {
|
|||||||
static char_u e_nul_found[] = N_("E865: (NFA) Regexp end encountered prematurely");
|
static char_u e_nul_found[] = N_("E865: (NFA) Regexp end encountered prematurely");
|
||||||
static char_u e_misplaced[] = N_("E866: (NFA regexp) Misplaced %c");
|
static char_u e_misplaced[] = N_("E866: (NFA regexp) Misplaced %c");
|
||||||
static char_u e_ill_char_class[] = N_("E877: (NFA regexp) Invalid character class: %d");
|
static char_u e_ill_char_class[] = N_("E877: (NFA regexp) Invalid character class: %d");
|
||||||
|
static char_u e_value_too_large[] = N_("E951: \\% value too large");
|
||||||
|
|
||||||
// Variables only used in nfa_regcomp() and descendants.
|
// Variables only used in nfa_regcomp() and descendants.
|
||||||
static int nfa_re_flags; // re_flags passed to nfa_regcomp()
|
static int nfa_re_flags; // re_flags passed to nfa_regcomp()
|
||||||
@@ -1541,19 +1542,27 @@ nfa_regatom(void)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
long n = 0;
|
long_u n = 0;
|
||||||
int cmp = c;
|
int cmp = c;
|
||||||
|
|
||||||
if (c == '<' || c == '>')
|
if (c == '<' || c == '>')
|
||||||
c = getchr();
|
c = getchr();
|
||||||
while (VIM_ISDIGIT(c))
|
while (VIM_ISDIGIT(c))
|
||||||
{
|
{
|
||||||
n = n * 10 + (c - '0');
|
long_u tmp = n * 10 + (c - '0');
|
||||||
|
|
||||||
|
if (tmp < n)
|
||||||
|
{
|
||||||
|
// overflow.
|
||||||
|
emsg(_(e_value_too_large));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
n = tmp;
|
||||||
c = getchr();
|
c = getchr();
|
||||||
}
|
}
|
||||||
if (c == 'l' || c == 'c' || c == 'v')
|
if (c == 'l' || c == 'c' || c == 'v')
|
||||||
{
|
{
|
||||||
int limit = INT_MAX;
|
long_u limit = INT_MAX;
|
||||||
|
|
||||||
if (c == 'l')
|
if (c == 'l')
|
||||||
{
|
{
|
||||||
@@ -1576,7 +1585,7 @@ nfa_regatom(void)
|
|||||||
}
|
}
|
||||||
if (n >= limit)
|
if (n >= limit)
|
||||||
{
|
{
|
||||||
emsg(_("E951: \\% value too large"));
|
emsg(_(e_value_too_large));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
EMIT((int)n);
|
EMIT((int)n);
|
||||||
|
|||||||
@@ -746,6 +746,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 */
|
||||||
|
/**/
|
||||||
|
892,
|
||||||
/**/
|
/**/
|
||||||
891,
|
891,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user