BIND 10 #972: Resolver class is not exception safe
BIND 10 Development
do-not-reply at isc.org
Wed May 25 19:14:00 UTC 2011
#972: Resolver class is not exception safe
---------------------------------+-----------------------------------------
Reporter: jinmei | Owner:
Type: defect | Status: new
Priority: major | Milestone: New Tasks
Component: resolver | Keywords:
Sensitive: 0 | Defect Severity: N/A
Sub-Project: DNS | Feature Depending on Ticket:
Estimated Difficulty: 0 | Add Hours to Ticket: 0
Total Hours: 0 | Internal?: 0
---------------------------------+-----------------------------------------
As I looked at the code for #971, I noticed another problem in the
Resolver class: Its constructor is not exception safe:
{{{
Resolver::Resolver() :
impl_(new ResolverImpl()),
dnss_(NULL),
checkin_(new ConfigCheck(this)),
dns_lookup_(new MessageLookup(this)),
dns_answer_(new MessageAnswer),
nsas_(NULL),
cache_(NULL),
configured_(false)
{}
}}}
If, for example, "new ConfigCheck" fails, the allocated resource for
impl_ will leak.
It also looks quite awkward that it has specific member variables even
if it adopts the pimpl idiom (although there may be a specific reason
that can only be understood via deep understanding of the
implementation details).
Furthermore, due to the fact that dnss_/nsas_/cache_ are not set (to a
non NULL value) at the construction time this class is quite fragile
because some methods naively assumes they are non NULL. Example:
{{{
void
Resolver::setForwardAddresses(const AddressList& addresses)
{
impl_->setForwardAddresses(addresses, dnss_);
}
}}}
I'd suggest heavy refactoring and cleanup for this class so that it
will be cleaner and safer.
--
Ticket URL: <http://bind10.isc.org/ticket/972>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development
More information about the bind10-tickets
mailing list