Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c0dd80e

Browse files
committed
1 << 31 is invalid for signed integers, fix it by making 1 unsigned.
Found by Clang trunk's Undefined-Behavior Sanitizer. [more to come]
2 parents c474c4e + 90555d0 commit c0dd80e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Modules/_sre.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ SRE_CHARSET(SRE_CODE* set, SRE_CODE ch)
427427
}
428428
else {
429429
/* <CHARSET> <bitmap> (32 bits per code word) */
430-
if (ch < 256 && (set[ch >> 5] & (1 << (ch & 31))))
430+
if (ch < 256 && (set[ch >> 5] & (1u << (ch & 31))))
431431
return ok;
432432
set += 8;
433433
}
@@ -466,7 +466,7 @@ SRE_CHARSET(SRE_CODE* set, SRE_CODE ch)
466466
block = -1;
467467
set += 64;
468468
if (block >=0 &&
469-
(set[block*8 + ((ch & 255)>>5)] & (1 << (ch & 31))))
469+
(set[block*8 + ((ch & 255)>>5)] & (1u << (ch & 31))))
470470
return ok;
471471
set += count*8;
472472
}

0 commit comments

Comments
 (0)