tests: Fix memory leak from sd_bus calls
Some of the calls into sd_bus leak memory because they never unreference
the bus or messages. Fix this so we can eventually enable leak checking
from valgrind.
Tested:
Ran through valgrind and the errors went away.
Change-Id: Icc3d5d0860b3852401219c1ca511a1bc26aa1c48
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/message/append.cpp b/test/message/append.cpp
index c56402a..b067e18 100644
--- a/test/message/append.cpp
+++ b/test/message/append.cpp
@@ -28,7 +28,8 @@
// Thread to run the dbus server.
void* server(void* b)
{
- auto bus = sdbusplus::bus::bus(reinterpret_cast<sdbusplus::bus::busp_t>(b));
+ auto bus = sdbusplus::bus::bus(reinterpret_cast<sdbusplus::bus::busp_t>(b),
+ std::false_type());
while (1)
{
@@ -62,8 +63,11 @@
{
// Reply and exit.
sd_bus_reply_method_return(m, nullptr);
+ sd_bus_message_unref(m);
break;
}
+
+ sd_bus_message_unref(m);
}
return nullptr;