Do not call handler blocks if they are nil

This commit is contained in:
Levin Li 2021-11-17 21:35:49 +08:00 committed by Levin Li
parent e68b97d58b
commit 5b151c5fa0
12 changed files with 32 additions and 33 deletions

View file

@ -3579,7 +3579,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
{
if (deallocator != NULL)
{
CALL_BLOCK(((GSDataDeallocatorBlock)deallocator), bytes, length);
CALL_NON_NULL_BLOCK(((GSDataDeallocatorBlock)deallocator), bytes, length);
DESTROY(deallocator);
}
// Clear out the ivars so that super doesn't double free.
@ -4442,7 +4442,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
{
if (deallocator != NULL)
{
CALL_BLOCK(((GSDataDeallocatorBlock)deallocator), bytes, capacity);
CALL_NON_NULL_BLOCK(((GSDataDeallocatorBlock)deallocator), bytes, capacity);
// Clear out the ivars so that super doesn't double free.
bytes = NULL;
length = 0;
@ -4472,7 +4472,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
memcpy(tmp, bytes, capacity < size ? capacity : size);
if (deallocator != NULL)
{
CALL_BLOCK(((GSDataDeallocatorBlock)deallocator), bytes, capacity);
CALL_NON_NULL_BLOCK(((GSDataDeallocatorBlock)deallocator), bytes, capacity);
DESTROY(deallocator);
zone = NSDefaultMallocZone();
}
@ -4483,7 +4483,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
}
else if (deallocator != NULL)
{
CALL_BLOCK(((GSDataDeallocatorBlock)deallocator), bytes, capacity);
CALL_NON_NULL_BLOCK(((GSDataDeallocatorBlock)deallocator), bytes, capacity);
DESTROY(deallocator);
zone = NSDefaultMallocZone();
}