|  | @@ -237,6 +237,10 @@ void * alloc_memblock ( size_t size, size_t align, size_t offset ) {
 | 
		
	
		
			
			| 237 | 237 |  	struct memory_block *post;
 | 
		
	
		
			
			| 238 | 238 |  	struct memory_block *ptr;
 | 
		
	
		
			
			| 239 | 239 |  
 | 
		
	
		
			
			|  | 240 | +	/* Sanity checks */
 | 
		
	
		
			
			|  | 241 | +	assert ( size != 0 );
 | 
		
	
		
			
			|  | 242 | +	assert ( ( align == 0 ) || ( ( align & ( align - 1 ) ) == 0 ) );
 | 
		
	
		
			
			|  | 243 | +
 | 
		
	
		
			
			| 240 | 244 |  	valgrind_make_blocks_defined();
 | 
		
	
		
			
			| 241 | 245 |  
 | 
		
	
		
			
			| 242 | 246 |  	/* Round up size to multiple of MIN_MEMBLOCK_SIZE and
 | 
		
	
	
		
			
			|  | @@ -338,6 +342,7 @@ void free_memblock ( void *ptr, size_t size ) {
 | 
		
	
		
			
			| 338 | 342 |  	/* Round up size to match actual size that alloc_memblock()
 | 
		
	
		
			
			| 339 | 343 |  	 * would have used.
 | 
		
	
		
			
			| 340 | 344 |  	 */
 | 
		
	
		
			
			|  | 345 | +	assert ( size != 0 );
 | 
		
	
		
			
			| 341 | 346 |  	size = ( size + MIN_MEMBLOCK_SIZE - 1 ) & ~( MIN_MEMBLOCK_SIZE - 1 );
 | 
		
	
		
			
			| 342 | 347 |  	freeing = ptr;
 | 
		
	
		
			
			| 343 | 348 |  	VALGRIND_MAKE_MEM_DEFINED ( freeing, sizeof ( *freeing ) );
 | 
		
	
	
		
			
			|  | @@ -444,6 +449,7 @@ void * realloc ( void *old_ptr, size_t new_size ) {
 | 
		
	
		
			
			| 444 | 449 |  					   data );
 | 
		
	
		
			
			| 445 | 450 |  		VALGRIND_MAKE_MEM_DEFINED ( old_block, offsetof ( struct autosized_block, data ) );
 | 
		
	
		
			
			| 446 | 451 |  		old_total_size = old_block->size;
 | 
		
	
		
			
			|  | 452 | +		assert ( old_total_size != 0 );
 | 
		
	
		
			
			| 447 | 453 |  		old_size = ( old_total_size -
 | 
		
	
		
			
			| 448 | 454 |  			     offsetof ( struct autosized_block, data ) );
 | 
		
	
		
			
			| 449 | 455 |  		memcpy ( new_ptr, old_ptr,
 |