mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 02:09:59 -04:00
Don't use ssize_t for storing difference between sizes
As POSIX guarantees only that the type ssize_t shall be capable of
storing values at least in the range [-1, {SSIZE_MAX}], it can't be used
to calculate the difference between two memory sizes. Change the logic
for junk filling to test whether the new size is larger than old size
and then use size_t as the result will be always positive.
This commit is contained in:
parent
560047307d
commit
f689dc2297
1 changed files with 3 additions and 3 deletions
|
|
@ -339,9 +339,9 @@ mem_realloc(isc_mem_t *ctx, void *old_ptr, size_t old_size, size_t new_size,
|
|||
if ((flags & ISC__MEM_ZERO) == 0 &&
|
||||
(ctx->flags & ISC_MEMFLAG_FILL) != 0)
|
||||
{
|
||||
ssize_t diff_size = new_size - old_size;
|
||||
void *diff_ptr = (uint8_t *)new_ptr + old_size;
|
||||
if (diff_size > 0) {
|
||||
if (new_size > old_size) {
|
||||
size_t diff_size = new_size - old_size;
|
||||
void *diff_ptr = (uint8_t *)new_ptr + old_size;
|
||||
/* Mnemonic for "beef". */
|
||||
memset(diff_ptr, 0xbe, diff_size);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue