From ab1c85830c0c5c241a6fe071e2d7f18c335f1519 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 8 Oct 2024 10:38:45 -0700 Subject: [PATCH] gtk/accessibletext: handle NULL default values The default implementation for get_default_attributes() returns NULL for both names and values yet the code which iterates them is assuming they will never be NULL. Since the interface implies that if the values are set, they will return valid strings, make the default implementation do that. Fixes: #7069 --- gtk/gtkaccessibletext.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gtk/gtkaccessibletext.c b/gtk/gtkaccessibletext.c index a635105fe9..0c2ef11cc8 100644 --- a/gtk/gtkaccessibletext.c +++ b/gtk/gtkaccessibletext.c @@ -68,8 +68,8 @@ gtk_accessible_text_default_get_default_attributes (GtkAccessibleText *self, char ***attribute_names, char ***attribute_values) { - *attribute_names = NULL; - *attribute_values = NULL; + *attribute_names = g_new0 (char *, 1); + *attribute_values = g_new0 (char *, 1); } static void @@ -289,10 +289,7 @@ gtk_accessible_text_get_attributes (GtkAccessibleText *self, * - a name, typically in the form of a reverse DNS identifier * - a value * - * If this function returns true, `n_attributes` will be set to a value - * greater than or equal to one, @ranges will be set to a newly - * allocated array of [struct#Gtk.AccessibleTextRange] which should - * be freed with g_free(), @attribute_names and @attribute_values + * If this function returns true, @attribute_names and @attribute_values * will be set to string arrays that should be freed with g_strfreev(). * * Since: 4.14