Fix sanitizer issue
Resolve heap-use-after-free issue that started appearing after
googletest update. According to docs, AddGlobalTestEnvironment takes
ownerwhip of an Environment object passed there and it's being destroyed
at the end of RUN_ALL_TESTS function. [1] Therefore any further usage of
that object will cause heap-use-after-free error.
Tested:
CI build passed
[1] https://google.github.io/googletest/advanced.html#global-set-up-and-tear-down
Change-Id: I517a7693a5692c4561de6a5e5ee8ebaf9d8cdc2d
Signed-off-by: Michal Orzel <michalx.orzel@intel.com>
diff --git a/tests/src/dbus_environment.cpp b/tests/src/dbus_environment.cpp
index dd00d94..bfe347c 100644
--- a/tests/src/dbus_environment.cpp
+++ b/tests/src/dbus_environment.cpp
@@ -7,7 +7,13 @@
DbusEnvironment::~DbusEnvironment()
{
- teardown();
+ if (setUp == true)
+ {
+ setUp = false;
+
+ objServer = nullptr;
+ bus = nullptr;
+ }
}
void DbusEnvironment::SetUp()
@@ -30,17 +36,6 @@
futures.clear();
}
-void DbusEnvironment::teardown()
-{
- if (setUp == true)
- {
- setUp = false;
-
- objServer = nullptr;
- bus = nullptr;
- }
-}
-
boost::asio::io_context& DbusEnvironment::getIoc()
{
return ioc;