1
0
forked from aniani/vim

patch 8.0.1254: undefined left shift in gethexchrs()

Problem:    Undefined left shift in gethexchrs(). (geeknik)
Solution:   Use unsigned long. (idea by Christian Brabandt, closes #2255)
This commit is contained in:
Bram Moolenaar
2017-11-02 22:29:38 +01:00
parent 430dc5d360
commit 4c22a91d20
3 changed files with 19 additions and 17 deletions

View File

@@ -695,9 +695,9 @@ static void skipchr_keepstart(void);
static int peekchr(void); static int peekchr(void);
static void skipchr(void); static void skipchr(void);
static void ungetchr(void); static void ungetchr(void);
static int gethexchrs(int maxinputlen); static long gethexchrs(int maxinputlen);
static int getoctchrs(void); static long getoctchrs(void);
static int getdecchrs(void); static long getdecchrs(void);
static int coll_get_char(void); static int coll_get_char(void);
static void regcomp_start(char_u *expr, int flags); static void regcomp_start(char_u *expr, int flags);
static char_u *reg(int, int *); static char_u *reg(int, int *);
@@ -1837,7 +1837,7 @@ regpiece(int *flagp)
case Magic('@'): case Magic('@'):
{ {
int lop = END; int lop = END;
int nr; long nr;
nr = getdecchrs(); nr = getdecchrs();
switch (no_Magic(getchr())) switch (no_Magic(getchr()))
@@ -2278,7 +2278,7 @@ regatom(int *flagp)
case 'u': /* %uabcd hex 4 */ case 'u': /* %uabcd hex 4 */
case 'U': /* %U1234abcd hex 8 */ case 'U': /* %U1234abcd hex 8 */
{ {
int i; long i;
switch (c) switch (c)
{ {
@@ -3274,10 +3274,10 @@ ungetchr(void)
* The parameter controls the maximum number of input characters. This will be * The parameter controls the maximum number of input characters. This will be
* 2 when reading a \%x20 sequence and 4 when reading a \%u20AC sequence. * 2 when reading a \%x20 sequence and 4 when reading a \%u20AC sequence.
*/ */
static int static long
gethexchrs(int maxinputlen) gethexchrs(int maxinputlen)
{ {
int nr = 0; long_u nr = 0;
int c; int c;
int i; int i;
@@ -3293,17 +3293,17 @@ gethexchrs(int maxinputlen)
if (i == 0) if (i == 0)
return -1; return -1;
return nr; return (long)nr;
} }
/* /*
* Get and return the value of the decimal string immediately after the * Get and return the value of the decimal string immediately after the
* current position. Return -1 for invalid. Consumes all digits. * current position. Return -1 for invalid. Consumes all digits.
*/ */
static int static long
getdecchrs(void) getdecchrs(void)
{ {
int nr = 0; long_u nr = 0;
int c; int c;
int i; int i;
@@ -3320,7 +3320,7 @@ getdecchrs(void)
if (i == 0) if (i == 0)
return -1; return -1;
return nr; return (long)nr;
} }
/* /*
@@ -3331,10 +3331,10 @@ getdecchrs(void)
* blahblah\%o210asdf * blahblah\%o210asdf
* before-^ ^-after * before-^ ^-after
*/ */
static int static long
getoctchrs(void) getoctchrs(void)
{ {
int nr = 0; long_u nr = 0;
int c; int c;
int i; int i;
@@ -3350,7 +3350,7 @@ getoctchrs(void)
if (i == 0) if (i == 0)
return -1; return -1;
return nr; return (long)nr;
} }
/* /*
@@ -3360,7 +3360,7 @@ getoctchrs(void)
static int static int
coll_get_char(void) coll_get_char(void)
{ {
int nr = -1; long nr = -1;
switch (*regparse++) switch (*regparse++)
{ {

View File

@@ -1522,7 +1522,7 @@ nfa_regatom(void)
case 'u': /* %uabcd hex 4 */ case 'u': /* %uabcd hex 4 */
case 'U': /* %U1234abcd hex 8 */ case 'U': /* %U1234abcd hex 8 */
{ {
int nr; long nr;
switch (c) switch (c)
{ {
@@ -2040,7 +2040,7 @@ nfa_regpiece(void)
int greedy = TRUE; /* Braces are prefixed with '-' ? */ int greedy = TRUE; /* Braces are prefixed with '-' ? */
parse_state_T old_state; parse_state_T old_state;
parse_state_T new_state; parse_state_T new_state;
int c2; long c2;
int old_post_pos; int old_post_pos;
int my_post_start; int my_post_start;
int quest; int quest;

View File

@@ -761,6 +761,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 */
/**/
1254,
/**/ /**/
1253, 1253,
/**/ /**/