mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-21 17:41:35 -04:00
Fix dns_qpmulti_memusage() on empty dns_qpmulti_t instance
The dns_qpmulti_memusage() causes assertion failure when called on freshly created qpmulti instance because the qp->usage hasn't been allocated yet.
This commit is contained in:
parent
722ce92f10
commit
b2f653b332
2 changed files with 15 additions and 1 deletions
|
|
@ -1124,7 +1124,7 @@ dns_qpmulti_memusage(dns_qpmulti_t *multi) {
|
|||
|
||||
dns_qp_memusage_t memusage = dns_qp_memusage(qp);
|
||||
|
||||
if (qp->transaction_mode == QP_UPDATE) {
|
||||
if (qp->transaction_mode == QP_UPDATE && qp->usage != NULL) {
|
||||
memusage.bytes -= qp->usage[qp->bump].capacity;
|
||||
memusage.bytes += qp->usage[qp->bump].used *
|
||||
sizeof(dns_qpnode_t);
|
||||
|
|
|
|||
|
|
@ -378,8 +378,22 @@ ISC_RUN_TEST_IMPL(qpmulti) {
|
|||
isc_loopmgr_destroy();
|
||||
}
|
||||
|
||||
ISC_RUN_TEST_IMPL(qpmulti_memusage) {
|
||||
dns_qpmulti_t *qpm = NULL;
|
||||
dns_qp_memusage_t mu;
|
||||
|
||||
dns_qpmulti_create(isc_g_mctx, &test_methods, NULL, &qpm);
|
||||
|
||||
mu = dns_qpmulti_memusage(qpm);
|
||||
assert_int_equal(mu.leaves, 0);
|
||||
assert_int_equal(mu.used, 0);
|
||||
|
||||
dns_qpmulti_destroy(&qpm);
|
||||
}
|
||||
|
||||
ISC_TEST_LIST_START
|
||||
ISC_TEST_ENTRY(qpmulti)
|
||||
ISC_TEST_ENTRY(qpmulti_memusage)
|
||||
ISC_TEST_LIST_END
|
||||
|
||||
ISC_TEST_MAIN
|
||||
|
|
|
|||
Loading…
Reference in a new issue