From: Ondřej Surý Date: Mon, 12 Jul 2021 07:18:12 +0000 (+0200) Subject: Remove nonnull attribute from isc_mem_{get,allocate,reallocate} X-Git-Tag: v9.17.17~31^2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=ce03015d48ee01dff0cf009be04acce9814ac079;p=thirdparty%2Fbind9.git Remove nonnull attribute from isc_mem_{get,allocate,reallocate} 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. --- diff --git a/lib/isc/include/isc/mem.h b/lib/isc/include/isc/mem.h index bd72f865499..4937de070af 100644 --- a/lib/isc/include/isc/mem.h +++ b/lib/isc/include/isc/mem.h @@ -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);