mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 15:21:56 -05:00
Fix PoolAllocator::resize for too large p_new_size
The code had a subtle signed/unsigned bug -
```cpp
if( signed - unsigned < 0)
// signed - unsigned is unsigned in c++, so
if( unsigned < 0)
// and thus the if block will never be executed
```
Thus all the following code would be ran, including unnecessary retries
of compacting the pool.
(cherry picked from commit 2bbe6144ff)
This commit is contained in:
@@ -359,7 +359,7 @@ Error PoolAllocator::resize(ID p_mem, int p_new_size) {
|
||||
//p_new_size = align(p_new_size)
|
||||
int _free = free_mem; // - static_area_size;
|
||||
|
||||
if ((_free + aligned(e->len)) - alloc_size < 0) {
|
||||
if (uint32_t(_free + aligned(e->len)) < alloc_size) {
|
||||
mt_unlock();
|
||||
ERR_FAIL_V(ERR_OUT_OF_MEMORY);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user