]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove nonnull attribute from isc_mem_{get,allocate,reallocate}
authorOndřej Surý <ondrej@sury.org>
Mon, 12 Jul 2021 07:18:12 +0000 (09:18 +0200)
committerOndřej Surý <ondrej@sury.org>
Mon, 12 Jul 2021 08:02:18 +0000 (10:02 +0200)
The isc_mem_get(), isc_mem_allocate() and isc_mem_reallocate() can
return NULL ptr in case where the allocation size is NULL.  Remove the
nonnull attribute from the functions' declarations.

This stems from the following definition in the C11 standard:

> If the size of the space requested is zero, the behavior is
> implementation-defined: either a null pointer is returned, or the
> behavior is as if the size were some nonzero value, except that the
> returned pointer shall not be used to access an object.

In this case, we return NULL as it's easier to detect errors when
accessing pointer from zero-sized allocation which should obviously
never happen.

lib/isc/include/isc/mem.h

index bd72f86549997d90c16b072b90fb09b1820a665b..4937de070af17dbf0bcb2ceea9b2d4e954a3b6bf 100644 (file)
@@ -475,15 +475,12 @@ void ISCMEMFUNC(putanddetach)(isc_mem_t **, void *, size_t _ISC_MEM_FLARG);
 void ISCMEMFUNC(put)(isc_mem_t *, void *, size_t _ISC_MEM_FLARG);
 void ISCMEMFUNC(free)(isc_mem_t *, void *_ISC_MEM_FLARG);
 
-ISC_ATTR_RETURNS_NONNULL
 ISC_ATTR_MALLOC_DEALLOCATOR_IDX(ISCMEMFUNC(put), 2)
 void *ISCMEMFUNC(get)(isc_mem_t *, size_t _ISC_MEM_FLARG);
 
-ISC_ATTR_RETURNS_NONNULL
 ISC_ATTR_MALLOC_DEALLOCATOR_IDX(ISCMEMFUNC(free), 2)
 void *ISCMEMFUNC(allocate)(isc_mem_t *, size_t _ISC_MEM_FLARG);
 
-ISC_ATTR_RETURNS_NONNULL
 ISC_ATTR_DEALLOCATOR_IDX(ISCMEMFUNC(free), 2)
 void *ISCMEMFUNC(reallocate)(isc_mem_t *, void *, size_t _ISC_MEM_FLARG);