mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 02:59:59 -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.
(cherry picked from commit b2f653b332)
This commit is contained in:
parent
1cbd8b8556
commit
f65c7b0c02
2 changed files with 15 additions and 1 deletions
|
|
@ -1108,7 +1108,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);
|
||||
|
|
|
|||
|
|
@ -394,8 +394,22 @@ ISC_RUN_TEST_IMPL(qpmulti) {
|
|||
isc_log_destroy(&dns_lctx);
|
||||
}
|
||||
|
||||
ISC_RUN_TEST_IMPL(qpmulti_memusage) {
|
||||
dns_qpmulti_t *qpm = NULL;
|
||||
dns_qp_memusage_t mu;
|
||||
|
||||
dns_qpmulti_create(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