2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

[master] buffer ATF test was failing

This commit is contained in:
Evan Hunt
2014-11-15 00:56:17 -08:00
parent ed51a21730
commit 907e01d6f3
2 changed files with 7 additions and 6 deletions

View File

@@ -505,20 +505,21 @@ isc_buffer_reserve(isc_buffer_t **dynbuffer, unsigned int size) {
REQUIRE(ISC_BUFFER_VALID(*dynbuffer));
len = (*dynbuffer)->length;
if ((len - (*dynbuffer)->used) > size)
if ((len - (*dynbuffer)->used) >= size)
return (ISC_R_SUCCESS);
/* Round to nearest buffer size increment */
len += size;
len = size + (*dynbuffer)->used;
len = (len + ISC_BUFFER_INCR - 1 - ((len - 1) % ISC_BUFFER_INCR));
/* Cap at UINT_MAX */
if (len > UINT_MAX) {
len = UINT_MAX;
if ((len - (*dynbuffer)->used) < size)
return (ISC_R_NOMEMORY);
}
if ((len - (*dynbuffer)->used) < size)
return (ISC_R_NOMEMORY);
return (isc_buffer_reallocate(dynbuffer, (unsigned int) len));
}