Skip to content

Commit 3d42986

Browse files
committed
Fix shift UB in constants
We were shifting out the top bit of a signed integer.
1 parent 11f30d6 commit 3d42986

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Zend/zend_alloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ static zend_always_inline void zend_mm_bitset_reset_range(zend_mm_bitset *bitset
591591

592592
if (pos != end) {
593593
/* reset bits from "bit" to ZEND_MM_BITSET_LEN-1 */
594-
tmp = ~((Z_L(1) << bit) - 1);
594+
tmp = ~((Z_UL(1) << bit) - 1);
595595
bitset[pos++] &= ~tmp;
596596
while (pos != end) {
597597
/* set all bits */

Zend/zend_compile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ struct _zend_execute_data {
516516
#define ZEND_CALL_FAKE_CLOSURE (1 << 23)
517517
#define ZEND_CALL_GENERATOR (1 << 24)
518518
#define ZEND_CALL_DYNAMIC (1 << 25)
519-
#define ZEND_CALL_SEND_ARG_BY_REF (1 << 31)
519+
#define ZEND_CALL_SEND_ARG_BY_REF (1u << 31)
520520

521521
#define ZEND_CALL_NESTED_FUNCTION (ZEND_CALL_FUNCTION | ZEND_CALL_NESTED)
522522
#define ZEND_CALL_NESTED_CODE (ZEND_CALL_CODE | ZEND_CALL_NESTED)

Zend/zend_gc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@
7878
#endif
7979

8080
/* GC_INFO layout */
81-
#define GC_ADDRESS 0x0fffff
82-
#define GC_COLOR 0x300000
81+
#define GC_ADDRESS 0x0fffffu
82+
#define GC_COLOR 0x300000u
8383

84-
#define GC_BLACK 0x000000 /* must be zero */
85-
#define GC_WHITE 0x100000
86-
#define GC_GREY 0x200000
87-
#define GC_PURPLE 0x300000
84+
#define GC_BLACK 0x000000u /* must be zero */
85+
#define GC_WHITE 0x100000u
86+
#define GC_GREY 0x200000u
87+
#define GC_PURPLE 0x300000u
8888

8989
/* GC_INFO access */
9090
#define GC_REF_ADDRESS(ref) \

0 commit comments

Comments
 (0)