mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 22:45:39 +00:00
Merge branch '3845-mem-zero-non-zero' into 'main'
Fix ISC_MEM_ZERO on allocators with malloc_usable_size() Closes #3845 See merge request isc-projects/bind9!7481
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -1,3 +1,6 @@
|
|||||||
|
6084. [bug] When BIND was built without jemalloc, the allocator flag
|
||||||
|
ISC_MEM_ZERO could return non-zero memory. [GL #3845]
|
||||||
|
|
||||||
6083. [bug] Fix DNSRPS-enabled builds as they were inadvertently
|
6083. [bug] Fix DNSRPS-enabled builds as they were inadvertently
|
||||||
broken by changes 5949 and 6042. [GL #3827]
|
broken by changes 5949 and 6042. [GL #3827]
|
||||||
|
|
||||||
|
@@ -66,7 +66,7 @@ mallocx(size_t size, int flags) {
|
|||||||
INSIST(ptr != NULL);
|
INSIST(ptr != NULL);
|
||||||
|
|
||||||
if ((flags & MALLOCX_ZERO) != 0) {
|
if ((flags & MALLOCX_ZERO) != 0) {
|
||||||
memset(ptr, 0, size);
|
memset(ptr, 0, sallocx(ptr, flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ptr);
|
return (ptr);
|
||||||
@@ -83,7 +83,7 @@ sdallocx(void *ptr, size_t size, int flags) {
|
|||||||
static inline void *
|
static inline void *
|
||||||
rallocx(void *ptr, size_t size, int flags) {
|
rallocx(void *ptr, size_t size, int flags) {
|
||||||
void *new_ptr;
|
void *new_ptr;
|
||||||
size_t old_size;
|
size_t old_size, new_size;
|
||||||
|
|
||||||
REQUIRE(size != 0);
|
REQUIRE(size != 0);
|
||||||
|
|
||||||
@@ -94,8 +94,12 @@ rallocx(void *ptr, size_t size, int flags) {
|
|||||||
new_ptr = realloc(ptr, size);
|
new_ptr = realloc(ptr, size);
|
||||||
INSIST(new_ptr != NULL);
|
INSIST(new_ptr != NULL);
|
||||||
|
|
||||||
if ((flags & MALLOCX_ZERO) != 0 && size > old_size) {
|
if ((flags & MALLOCX_ZERO) != 0) {
|
||||||
memset((uint8_t *)new_ptr + old_size, 0, size - old_size);
|
new_size = sallocx(new_ptr, flags);
|
||||||
|
if (new_size > old_size) {
|
||||||
|
memset((uint8_t *)new_ptr + old_size, 0,
|
||||||
|
new_size - old_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (new_ptr);
|
return (new_ptr);
|
||||||
|
Reference in New Issue
Block a user