mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Keep right operand within width when right shifting
NUM_IN_PAGE could return a value much larger than 64. According to the C11 spec 6.5.7 paragraph 3 this is undefined behavior: > If the value of the right operand is negative or is greater than or > equal to the width of the promoted left operand, the behavior is > undefined. On most platforms, this is usually not a problem as the architecture will mask off all out-of-range bits.
This commit is contained in:
parent
97ab2599f3
commit
87784fdeb2
Notes:
git
2022-01-25 04:34:36 +09:00
1 changed files with 1 additions and 1 deletions
2
gc.c
2
gc.c
|
@ -4956,7 +4956,7 @@ try_move(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_page,
|
|||
|
||||
bits_t bits = mark_bits[index] & ~pin_bits[index];
|
||||
|
||||
bits >>= NUM_IN_PAGE(p);
|
||||
bits >>= NUM_IN_PAGE(p) % BITS_BITLENGTH;
|
||||
if (try_move_plane(objspace, heap, sweep_page, (uintptr_t)p, bits, dest)) return 1;
|
||||
|
||||
if (index == 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue