From 0d61895ef1b4cf7a706841681322f53abc494543 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 8 Nov 2023 08:31:10 +0100 Subject: [PATCH] gutils: assert against calling g_set_application_name() g_set_application_name() guards against being reset, but it doesn't remember whether it was set, it only checks whether g_application_name was set to non-NULL. When allowing g_set_application_name(NULL) that leads to odd behaviors, like: g_set_application_name(NULL); g_set_application_name("foo"); would not warn. Disallow that and assert against a NULL application_name. Note that application_name argument is also not marked as "(nullable)". --- glib/gutils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/glib/gutils.c b/glib/gutils.c index 0ec4f66a1..58b87fe84 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -1232,7 +1232,9 @@ void g_set_application_name (const gchar *application_name) { gboolean already_set = FALSE; - + + g_return_if_fail (application_name); + G_LOCK (g_application_name); if (g_application_name) already_set = TRUE;