mirror of
				https://github.com/GrapheneOS/hardened_malloc.git
				synced 2025-11-03 01:06:33 +01:00 
			
		
		
		
	Simplify a bit write_after_free_check
No need to have a variable check when the preprocessor can do the job.
This commit is contained in:
		
							parent
							
								
									2b25c791ee
								
							
						
					
					
						commit
						3572544b81
					
				
					 1 changed files with 2 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -439,15 +439,13 @@ static void *slot_pointer(size_t size, void *slab, size_t slot) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void write_after_free_check(const char *p, size_t size) {
 | 
			
		||||
    if (!WRITE_AFTER_FREE_CHECK) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#ifdef WRITE_AFTER_FREE_CHECK
 | 
			
		||||
    for (size_t i = 0; i < size; i += sizeof(u64)) {
 | 
			
		||||
        if (*(const u64 *)(const void *)(p + i)) {
 | 
			
		||||
            fatal_error("detected write after free");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const u64 canary_mask = __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ ?
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue