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.
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);
}