mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:12:44 +00:00 
			
		
		
		
	AK: Assert refcount doesn't overflow
We don't really have a good way to prevent this kind of overflow, but let's at least immediately panic in this case.
This commit is contained in:
		
							parent
							
								
									c80e657dda
								
							
						
					
					
						commit
						0ff3c1c34d
					
				
					 1 changed files with 2 additions and 0 deletions
				
			
		|  | @ -28,6 +28,7 @@ | |||
| 
 | ||||
| #include <AK/Assertions.h> | ||||
| #include <AK/Atomic.h> | ||||
| #include <AK/Checked.h> | ||||
| #include <AK/Platform.h> | ||||
| #include <AK/StdLibExtras.h> | ||||
| 
 | ||||
|  | @ -65,6 +66,7 @@ public: | |||
|     { | ||||
|         auto old_ref_count = m_ref_count++; | ||||
|         ASSERT(old_ref_count > 0); | ||||
|         ASSERT(!Checked<RefCountType>::addition_would_overflow(old_ref_count, 1)); | ||||
|     } | ||||
| 
 | ||||
|     ALWAYS_INLINE RefCountType ref_count() const | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sergey Bugaev
						Sergey Bugaev