Commit adf2b45f authored by KIM JungYong's avatar KIM JungYong Committed by Uze Choi

Fix for double free in RE cache unit test.

[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: default avatarKIM JungYong <jyong2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18893Reviewed-by: default avatarJay  Sharma <jay.sharma@samsung.com>
Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
parent 17b7f943
......@@ -57,7 +57,8 @@ class DataCacheTest : public TestWithMock
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()))
......
......@@ -47,7 +47,8 @@ class ResourceCacheManagerTest : public TestWithMock
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment