[Problem]
When RE cache unit test is terminated,
always will crash af double free.
[Reason]
double freed valiable is shared pointer of mock object.
this pointer will remove twice on release of mock object and shared pointer.
[Fix]
Deleter as non-operation was added on the creation of shared pointer.
Change-Id: I6434795fd011312b1a9bcb5ecf0d092aab19b487
Signed-off-by: KIM JungYong <jyong2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18893
Reviewed-by: Jay Sharma <jay.sharma@samsung.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
std::call_once(flag, [this]()
{
isLast = false;
- pResource = PrimitiveResource::Ptr(mocks.Mock< PrimitiveResource >());
+ auto deleter = [](PrimitiveResource *) { };
+ pResource = PrimitiveResource::Ptr(mocks.Mock< PrimitiveResource >(), deleter);
});
}
virtual ~DataCacheTest() noexcept(noexcept(std::declval<Test>().~Test()))
std::call_once(flag, [this]()
{
isLast = false;
- pResource = PrimitiveResource::Ptr(mocks.Mock< PrimitiveResource >());
+ auto deleter = [](PrimitiveResource *) { };
+ pResource = PrimitiveResource::Ptr(mocks.Mock< PrimitiveResource >(), deleter);
});
mocks.OnCall(pResource.get(), PrimitiveResource::isObservable).Return(false);
cb = ([](std::shared_ptr<PrimitiveResource >, const RCSResourceAttributes &)->OCStackResult