vim-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 vim/vim#6193)
c5acc0f7fe
This commit is contained in:
Jan Edmund Lazo 2020-06-03 23:22:23 -04:00
parent ed85d68123
commit 0fa2aefb61
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15

View File

@ -249,6 +249,7 @@ static char_u e_nul_found[] = N_(
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: %" PRId64);
static char_u e_value_too_large[] = N_("E951: \\% value too large");
/* Since the out pointers in the list are always
* uninitialized, we use the pointers themselves
@ -1499,7 +1500,8 @@ static int nfa_regatom(void)
c = getchr();
while (ascii_isdigit(c)) {
if (n > (INT32_MAX - (c - '0')) / 10) {
EMSG(_("E951: \\% value too large"));
// overflow.
EMSG(_(e_value_too_large));
return FAIL;
}
n = n * 10 + (c - '0');
@ -1526,7 +1528,7 @@ static int nfa_regatom(void)
limit = INT32_MAX / MB_MAXBYTES;
}
if (n >= limit) {
EMSG(_("E951: \\% value too large"));
EMSG(_(e_value_too_large));
return FAIL;
}
EMIT((int)n);