mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
mem_maybedup() can no longer fail
mem_maybedup() calls isc_mem_allocate() if an mctx is supplied, but that can no longer fail, so now the only way mem_maybedup() could return NULL is if it was given a NULL source address by the caller. this commit adds a REQUIRE to prevent that scenario, and cleans up all the calling code that previously checked for NULL return values. this function is mostly used in rdata tostruct() implementations, so the documentation for dns_rdata_tostruct() has been updated to remove 'ISC_R_NOMEMORY' as a possible return value.
This commit is contained in:
@@ -420,11 +420,14 @@ name_duporclone(const dns_name_t *source, isc_mem_t *mctx, dns_name_t *target) {
|
||||
|
||||
static inline void *
|
||||
mem_maybedup(isc_mem_t *mctx, void *source, size_t length) {
|
||||
void *copy;
|
||||
void *copy = NULL;
|
||||
|
||||
REQUIRE(source != NULL);
|
||||
|
||||
if (mctx == NULL) {
|
||||
return (source);
|
||||
}
|
||||
|
||||
copy = isc_mem_allocate(mctx, length);
|
||||
memmove(copy, source, length);
|
||||
|
||||
|
Reference in New Issue
Block a user