GDBus CXX (dbus-1 and gio): avoid uninitialized memory access in SignalWatch
If the watch was never activated, m_tag was never set, which led to an invalid memory read in the destructor. Also be more careful with using the connection and better check that it still exists.
This commit is contained in:
parent
ad513df9cd
commit
379ecd7d78
2 changed files with 10 additions and 4 deletions
|
@ -4088,14 +4088,17 @@ template <class T> class SignalWatch
|
|||
public:
|
||||
SignalWatch(const DBusRemoteObject &object,
|
||||
const std::string &signal)
|
||||
: m_object(object), m_signal(signal)
|
||||
: m_object(object), m_signal(signal), m_tag(0)
|
||||
{
|
||||
}
|
||||
|
||||
~SignalWatch()
|
||||
{
|
||||
if (m_tag) {
|
||||
b_dbus_remove_watch(m_object.getConnection(), m_tag);
|
||||
DBusConnection *connection = m_object.getConnection();
|
||||
if (connection) {
|
||||
b_dbus_remove_watch(connection, m_tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4069,14 +4069,17 @@ template <class T> class SignalWatch
|
|||
public:
|
||||
SignalWatch(const DBusRemoteObject &object,
|
||||
const std::string &signal)
|
||||
: m_object(object), m_signal(signal)
|
||||
: m_object(object), m_signal(signal), m_tag(0)
|
||||
{
|
||||
}
|
||||
|
||||
~SignalWatch()
|
||||
{
|
||||
if (m_tag) {
|
||||
g_dbus_connection_signal_unsubscribe(m_object.getConnection(), m_tag);
|
||||
GDBusConnection *connection = m_object.getConnection();
|
||||
if (connection) {
|
||||
g_dbus_connection_signal_unsubscribe(connection, m_tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue