mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 06:25:34 +00:00
[2275] valgrind fix: store singleton instance in auto_ptr
This commit is contained in:
@@ -106,10 +106,10 @@ internal::RequestCheckCreator::create(const string& name,
|
|||||||
|
|
||||||
RequestLoader&
|
RequestLoader&
|
||||||
getRequestLoader() {
|
getRequestLoader() {
|
||||||
static RequestLoader* loader(NULL);
|
static auto_ptr<RequestLoader> loader(NULL);
|
||||||
if (loader == NULL) {
|
if (loader.get() == NULL) {
|
||||||
// Creator registration may throw, so we first store the new loader
|
// Creator registration may throw, so we first store the new loader
|
||||||
// in an auto pointer in order to provide the strong exception
|
// in a second auto pointer in order to provide the strong exception
|
||||||
// guarantee.
|
// guarantee.
|
||||||
auto_ptr<RequestLoader> loader_ptr =
|
auto_ptr<RequestLoader> loader_ptr =
|
||||||
auto_ptr<RequestLoader>(new RequestLoader(REJECT));
|
auto_ptr<RequestLoader>(new RequestLoader(REJECT));
|
||||||
@@ -129,7 +129,7 @@ getRequestLoader() {
|
|||||||
new LogicCreator<AllOfSpec, RequestContext>("ALL")));
|
new LogicCreator<AllOfSpec, RequestContext>("ALL")));
|
||||||
|
|
||||||
// From this point there shouldn't be any exception thrown
|
// From this point there shouldn't be any exception thrown
|
||||||
loader = loader_ptr.release();
|
loader.reset(loader_ptr.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*loader);
|
return (*loader);
|
||||||
|
Reference in New Issue
Block a user