From 61807e9b6b0205bfd3de70f33b7a319eb58ebb10 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 28 Nov 2019 12:40:55 +0100 Subject: [PATCH] libnm: add assertion for object returned by nm_device_get_active_connection() I have a coredump that seems to indicate that nm_device_get_active_connection() did not return a valid object. Let's add an assertion, trying to identify the issue earlier. Aside from that, this change isn't useful, but an nm_assert() shouldn't hurt anyway. --- libnm/nm-client.c | 4 +++- libnm/nm-device.c | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libnm/nm-client.c b/libnm/nm-client.c index 4e5ad4598c..05ccdac3fa 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -3708,7 +3708,7 @@ _request_wait_start (GTask *task_take, } } -static gpointer * +static gpointer _request_wait_finish (NMClient *client, GAsyncResult *result, gpointer source_tag, @@ -3732,6 +3732,8 @@ _request_wait_finish (NMClient *client, NM_SET_OUT (out_result, g_steal_pointer (&request_data->extra_results)); r = g_steal_pointer (&request_data->result); + nm_assert (NM_IS_OBJECT (r)); + _request_wait_data_free (request_data); return r; } diff --git a/libnm/nm-device.c b/libnm/nm-device.c index 2160bbef06..ade67b0474 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -1418,9 +1418,14 @@ nm_device_get_state_reason (NMDevice *device) NMActiveConnection * nm_device_get_active_connection (NMDevice *device) { + NMActiveConnection *ac; + g_return_val_if_fail (NM_IS_DEVICE (device), NULL); - return nml_dbus_property_o_get_obj (&NM_DEVICE_GET_PRIVATE (device)->property_o[PROPERTY_O_IDX_ACTIVE_CONNECTION]); + ac = nml_dbus_property_o_get_obj (&NM_DEVICE_GET_PRIVATE (device)->property_o[PROPERTY_O_IDX_ACTIVE_CONNECTION]); + + nm_assert (!ac || NM_IS_ACTIVE_CONNECTION (ac)); + return ac; } /**