Showing
1 changed file
with
5 additions
and
3 deletions
... | ... | @@ -598,14 +598,16 @@ TR_malloc(size_t size) |
598 | 598 | if (size < 8) { |
599 | 599 | size = 8; |
600 | 600 | } else { |
601 | - size_t check = size; | |
602 | - size_t mask = 1; | |
601 | + size_t check = size >> 4; | |
602 | + size_t mask = 0x1F; | |
603 | 603 | |
604 | 604 | while (check >>= 1) { |
605 | 605 | mask = (mask << 1) | 1; |
606 | 606 | } |
607 | 607 | |
608 | - size = (size << 1) & ~mask; | |
608 | + if (size != (size & ~(mask >> 1))) { | |
609 | + size = (size << 1) & ~mask; | |
610 | + } | |
609 | 611 | } |
610 | 612 | } |
611 | 613 | ... | ... |
Please
register
or
login
to post a comment