diff options
author | Benjamin Otte <otte@redhat.com> | 2015-09-12 02:58:28 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2015-09-12 05:27:35 +0200 |
commit | 610452dda87e4142114448cef99956fcda93ca2b (patch) | |
tree | ee62e56391b311d36847975beee01d41d6e7200a /gtk/gtkcssnodedeclaration.c | |
parent | 6118893a4ea75d9f94e5e68ed1c8e0ae73442926 (diff) | |
download | gtk+-610452dda87e4142114448cef99956fcda93ca2b.tar.gz |
cssnode: Move clear_classes() into the NodeDeclaration
The previous code was crashing when used as the returned classes array
would have been invalid after the first deletion. So if a 2nd class
would be deleted, invalid memory might have been referenced.
Diffstat (limited to 'gtk/gtkcssnodedeclaration.c')
-rw-r--r-- | gtk/gtkcssnodedeclaration.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gtk/gtkcssnodedeclaration.c b/gtk/gtkcssnodedeclaration.c index c16189b1fe..8e425a4387 100644 --- a/gtk/gtkcssnodedeclaration.c +++ b/gtk/gtkcssnodedeclaration.c @@ -308,6 +308,21 @@ gtk_css_node_declaration_remove_class (GtkCssNodeDeclaration **decl, } gboolean +gtk_css_node_declaration_clear_classes (GtkCssNodeDeclaration **decl) +{ + if ((*decl)->n_classes == 0) + return FALSE; + + gtk_css_node_declaration_make_writable_resize (decl, + (char *) get_classes (*decl) - (char *) *decl, + 0, + sizeof (GQuark) * (*decl)->n_classes); + (*decl)->n_classes = 0; + + return TRUE; +} + +gboolean gtk_css_node_declaration_has_class (const GtkCssNodeDeclaration *decl, GQuark class_quark) { |