base: Fix UB
This commit is contained in:
		@@ -260,10 +260,13 @@ heim_cmp(heim_object_t a, heim_object_t b)
 | 
				
			|||||||
static void HEIM_CALLCONV
 | 
					static void HEIM_CALLCONV
 | 
				
			||||||
memory_dealloc(void *ptr)
 | 
					memory_dealloc(void *ptr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    if (ptr) {
 | 
				
			||||||
        struct heim_base_mem *p = (struct heim_base_mem *)PTR2BASE(ptr);
 | 
					        struct heim_base_mem *p = (struct heim_base_mem *)PTR2BASE(ptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (p->dealloc)
 | 
					        if (p->dealloc)
 | 
				
			||||||
            p->dealloc(ptr);
 | 
					            p->dealloc(ptr);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct heim_type_data memory_object = {
 | 
					struct heim_type_data memory_object = {
 | 
				
			||||||
    HEIM_TID_MEMORY,
 | 
					    HEIM_TID_MEMORY,
 | 
				
			||||||
@@ -672,13 +675,14 @@ heim_object_t
 | 
				
			|||||||
heim_auto_release(heim_object_t ptr)
 | 
					heim_auto_release(heim_object_t ptr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    struct heim_base *p;
 | 
					    struct heim_base *p;
 | 
				
			||||||
    struct ar_tls *tls = autorel_tls();
 | 
					    struct ar_tls *tls;
 | 
				
			||||||
    heim_auto_release_t ar;
 | 
					    heim_auto_release_t ar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (ptr == NULL || heim_base_is_tagged(ptr))
 | 
					    if (ptr == NULL || heim_base_is_tagged(ptr))
 | 
				
			||||||
	return ptr;
 | 
						return ptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    p = PTR2BASE(ptr);
 | 
					    p = PTR2BASE(ptr);
 | 
				
			||||||
 | 
					    tls = autorel_tls();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* drop from old pool */
 | 
					    /* drop from old pool */
 | 
				
			||||||
    if ((ar = p->autorelpool) != NULL) {
 | 
					    if ((ar = p->autorelpool) != NULL) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user