diff options
author | Ninni Pipping <over999ships@gmail.com> | 2023-03-10 17:25:28 +0100 |
---|---|---|
committer | Ninni Pipping <over999ships@gmail.com> | 2023-06-20 13:20:17 +0200 |
commit | e344bab8af93649b0e00fade9362b704b7205251 (patch) | |
tree | e14ab612a501d537d83a1fea809c5725d3ac9cbb | |
parent | dbe8712d4eda555829283624df7c79faa4bc02ea (diff) | |
download | redot-engine-e344bab8af93649b0e00fade9362b704b7205251.tar.gz |
Handle RID validator overflow
-rw-r--r-- | core/templates/rid_owner.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/templates/rid_owner.h b/core/templates/rid_owner.h index 9ccd7bb0bf..e2ffabdaf0 100644 --- a/core/templates/rid_owner.h +++ b/core/templates/rid_owner.h @@ -117,6 +117,7 @@ class RID_Alloc : public RID_AllocBase { uint32_t free_element = free_index % elements_in_chunk; uint32_t validator = (uint32_t)(_gen_id() & 0x7FFFFFFF); + CRASH_COND_MSG(validator == 0x7FFFFFFF, "Overflow in RID validator"); uint64_t id = validator; id <<= 32; id |= free_index; @@ -238,7 +239,7 @@ public: uint32_t validator = uint32_t(id >> 32); - bool owned = (validator_chunks[idx_chunk][idx_element] & 0x7FFFFFFF) == validator; + bool owned = (validator != 0x7FFFFFFF) && (validator_chunks[idx_chunk][idx_element] & 0x7FFFFFFF) == validator; if (THREAD_SAFE) { spin_lock.unlock(); |