Skip to content

Commit 4c22a91

Browse files
committed
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)
1 parent 430dc5d commit 4c22a91

3 files changed

Lines changed: 19 additions & 17 deletions

File tree

src/regexp.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,9 @@ static void skipchr_keepstart(void);
695695
static int peekchr(void);
696696
static void skipchr(void);
697697
static void ungetchr(void);
698-
static int gethexchrs(int maxinputlen);
699-
static int getoctchrs(void);
700-
static int getdecchrs(void);
698+
static long gethexchrs(int maxinputlen);
699+
static long getoctchrs(void);
700+
static long getdecchrs(void);
701701
static int coll_get_char(void);
702702
static void regcomp_start(char_u *expr, int flags);
703703
static char_u *reg(int, int *);
@@ -1837,7 +1837,7 @@ regpiece(int *flagp)
18371837
case Magic('@'):
18381838
{
18391839
int lop = END;
1840-
int nr;
1840+
long nr;
18411841

18421842
nr = getdecchrs();
18431843
switch (no_Magic(getchr()))
@@ -2278,7 +2278,7 @@ regatom(int *flagp)
22782278
case 'u': /* %uabcd hex 4 */
22792279
case 'U': /* %U1234abcd hex 8 */
22802280
{
2281-
int i;
2281+
long i;
22822282

22832283
switch (c)
22842284
{
@@ -3274,10 +3274,10 @@ ungetchr(void)
32743274
* The parameter controls the maximum number of input characters. This will be
32753275
* 2 when reading a \%x20 sequence and 4 when reading a \%u20AC sequence.
32763276
*/
3277-
static int
3277+
static long
32783278
gethexchrs(int maxinputlen)
32793279
{
3280-
int nr = 0;
3280+
long_u nr = 0;
32813281
int c;
32823282
int i;
32833283

@@ -3293,17 +3293,17 @@ gethexchrs(int maxinputlen)
32933293

32943294
if (i == 0)
32953295
return -1;
3296-
return nr;
3296+
return (long)nr;
32973297
}
32983298

32993299
/*
33003300
* Get and return the value of the decimal string immediately after the
33013301
* current position. Return -1 for invalid. Consumes all digits.
33023302
*/
3303-
static int
3303+
static long
33043304
getdecchrs(void)
33053305
{
3306-
int nr = 0;
3306+
long_u nr = 0;
33073307
int c;
33083308
int i;
33093309

@@ -3320,7 +3320,7 @@ getdecchrs(void)
33203320

33213321
if (i == 0)
33223322
return -1;
3323-
return nr;
3323+
return (long)nr;
33243324
}
33253325

33263326
/*
@@ -3331,10 +3331,10 @@ getdecchrs(void)
33313331
* blahblah\%o210asdf
33323332
* before-^ ^-after
33333333
*/
3334-
static int
3334+
static long
33353335
getoctchrs(void)
33363336
{
3337-
int nr = 0;
3337+
long_u nr = 0;
33383338
int c;
33393339
int i;
33403340

@@ -3350,7 +3350,7 @@ getoctchrs(void)
33503350

33513351
if (i == 0)
33523352
return -1;
3353-
return nr;
3353+
return (long)nr;
33543354
}
33553355

33563356
/*
@@ -3360,7 +3360,7 @@ getoctchrs(void)
33603360
static int
33613361
coll_get_char(void)
33623362
{
3363-
int nr = -1;
3363+
long nr = -1;
33643364

33653365
switch (*regparse++)
33663366
{

src/regexp_nfa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ nfa_regatom(void)
15221522
case 'u': /* %uabcd hex 4 */
15231523
case 'U': /* %U1234abcd hex 8 */
15241524
{
1525-
int nr;
1525+
long nr;
15261526

15271527
switch (c)
15281528
{
@@ -2040,7 +2040,7 @@ nfa_regpiece(void)
20402040
int greedy = TRUE; /* Braces are prefixed with '-' ? */
20412041
parse_state_T old_state;
20422042
parse_state_T new_state;
2043-
int c2;
2043+
long c2;
20442044
int old_post_pos;
20452045
int my_post_start;
20462046
int quest;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1254,
764766
/**/
765767
1253,
766768
/**/

0 commit comments

Comments
 (0)