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

Merge branch '474-mempool-is-broken-if-object-size-is-below-the-alignment-size' into 'master'

Resolve "mempool is broken if object size is below the alignment size"

Closes #474

See merge request isc-projects/bind9!635
This commit is contained in:
Evan Hunt
2018-08-14 04:09:17 -04:00
2 changed files with 21 additions and 0 deletions

View File

@@ -1841,6 +1841,12 @@ isc__mempool_create(isc_mem_t *mctx0, size_t size, isc_mempool_t **mpctxp) {
mpctx->common.magic = ISCAPI_MPOOL_MAGIC;
mpctx->lock = NULL;
mpctx->mctx = mctx;
/*
* Mempools are stored as a linked list of element.
*/
if (size < sizeof(element)) {
size = sizeof(element);
}
mpctx->size = size;
mpctx->maxalloc = UINT_MAX;
mpctx->allocated = 0;

View File

@@ -137,6 +137,21 @@ ATF_TC_BODY(isc_mem, tc) {
isc_mem_destroy(&localmctx);
result = isc_mem_createx2(0, 0, default_memalloc, default_memfree,
NULL, &localmctx,
ISC_MEMFLAG_FILL | ISC_MEMFLAG_INTERNAL);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
result = isc_mempool_create(localmctx, 2, &mp1);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
tmp = isc_mempool_get(mp1);
ATF_CHECK(tmp != NULL);
isc_mempool_put(mp1, tmp);
isc_mempool_destroy(&mp1);
isc_test_end();
}