[gtk] cssprovider: Don't add empty rulesets



commit 7523a3f2f2eed7e4b42113d94c0018f802fd7ed5
Author: Benjamin Otte <otte redhat com>
Date:   Sat Nov 23 19:01:28 2019 +0100

    cssprovider: Don't add empty rulesets
    
    This change was lost during the parser changes, but the newly added test
    exposes it.
    
    And fix the expected error, the syntax has changed.

 gtk/gtkcssprovider.c                          | 6 ++++++
 testsuite/css/parser/border-crash-3.24.errors | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 1aae733d27..5c4c6e9e2e 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -631,6 +631,12 @@ css_provider_commit (GtkCssProvider *css_provider,
   GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (css_provider);
   GSList *l;
 
+  if (ruleset->styles == NULL)
+    {
+      g_slist_free_full (selectors, (GDestroyNotify) _gtk_css_selector_free);
+      return;
+    }
+
   for (l = selectors; l; l = l->next)
     {
       GtkCssRuleset new;
diff --git a/testsuite/css/parser/border-crash-3.24.errors b/testsuite/css/parser/border-crash-3.24.errors
index c49f1d071a..f7b815aaf5 100644
--- a/testsuite/css/parser/border-crash-3.24.errors
+++ b/testsuite/css/parser/border-crash-3.24.errors
@@ -1 +1 @@
-border-crash-3.24.css:3: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
+border-crash-3.24.css:3:3-10: error: GTK_CSS_PARSER_ERROR_SYNTAX


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]