dhcp: fix crash in "nm-dhcp-helper" passing NULL to g_dbus_connection_flush_sync()

"connection" variable might be NULL, which fails an assertion in
g_dbus_connection_flush_sync(). Consequently, "error_flush" is also
NULL which leads to a crash of "nm-dhcp-helper".

Reported-by: Jules Maselbas <jmaselbas@zdiv.net>

Fixes: 240ec7f891 ('dhcp: implement ACD (address collision detection) for DHCPv4')
(cherry picked from commit 37e130232d)
This commit is contained in:
Thomas Haller 2022-12-05 21:57:17 +01:00
parent e4f5d96d6a
commit e4cc504af5
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -252,7 +252,7 @@ do_notify:
success = FALSE;
out:
if (!g_dbus_connection_flush_sync(connection, NULL, &error_flush)) {
if (connection && !g_dbus_connection_flush_sync(connection, NULL, &error_flush)) {
_LOGE("could not flush D-Bus connection: %s", error_flush->message);
/* if we considered this a success so far, don't fail because of this. */
}