Properly handle dbus errors when getting hostname

This commit is contained in:
Patrick Nicolas
2025-01-15 17:09:53 +01:00
parent d1b91c41e4
commit 88e7eb3c73
+5
View File
@@ -14,6 +14,7 @@ static std::string _hostname()
if (!con) if (!con)
{ {
U_LOG_W("Failed to connect to system bus: %s", error->message); U_LOG_W("Failed to connect to system bus: %s", error->message);
g_error_free(error);
} }
else else
{ {
@@ -32,7 +33,11 @@ static std::string _hostname()
&error); &error);
if (error) if (error)
{
g_error_free(error);
error = NULL;
continue; continue;
}
GVariant * property_value; GVariant * property_value;
g_variant_get(result, "(v)", &property_value); g_variant_get(result, "(v)", &property_value);