mirror of
				https://github.com/GrapheneOS/hardened_malloc.git
				synced 2025-11-03 01:06:33 +01:00 
			
		
		
		
	added check for if small allocations are free
This commit is contained in:
		
							parent
							
								
									5a3663376f
								
							
						
					
					
						commit
						af35f20f4f
					
				
					 1 changed files with 11 additions and 0 deletions
				
			
		
							
								
								
									
										11
									
								
								h_malloc.c
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								h_malloc.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1650,6 +1650,17 @@ EXPORT size_t h_malloc_object_size(void *p) {
 | 
			
		|||
        size_t slab_size = get_slab_size(size_class_slots[class], size_class);
 | 
			
		||||
        void *slab = get_slab(c, slab_size, metadata);
 | 
			
		||||
        size_t slot = libdivide_u32_do((const char *)p - (const char *)slab, &c->size_divisor);
 | 
			
		||||
 | 
			
		||||
        if (!get_slot(metadata, slot)) {
 | 
			
		||||
            fatal_error("invalid malloc_object_size");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#if SLAB_QUARANTINE
 | 
			
		||||
        if (get_quarantine(metadata, slot)) {
 | 
			
		||||
            fatal_error("invalid malloc_object_size (quarantine)");
 | 
			
		||||
        }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
        void *start = slot_pointer(size_class, slab, slot);
 | 
			
		||||
        size_t offset = (const char *)p - (const char *)start;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue