gdbusconnection: Fix a crash on arg0 matching

If a connection has two signal subscriptions active for the same signal,
one with arg0 matching and one without, a signal which doesn’t contain
an arg0 value (i.e. `g_dbus_message_get_arg0()` returns `NULL`) will
cause `NULL` to be passed to `strcmp()` when checking for a match
against the signal subscription which *has* arg0 matching, causing a
crash.

Fix that by adding the obvious `NULL` check, and add a unit test.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3342
This commit is contained in:
Philip Withnall
2024-04-30 18:33:57 +01:00
parent 740f2ea489
commit fd93e12669
2 changed files with 65 additions and 1 deletions

View File

@@ -3929,7 +3929,7 @@ schedule_callbacks (GDBusConnection *connection,
(arg0_path == NULL || !path_rule_matches (signal_data->arg0, arg0_path)))
continue;
}
else if (!g_str_equal (signal_data->arg0, arg0))
else if (arg0 == NULL || !g_str_equal (signal_data->arg0, arg0))
continue;
}