[gtk+] css: Fail animation shorthand parsing properly



commit d6e9997619fb6bfe082360f1702d6d29250dc3ce
Author: Benjamin Otte <otte redhat com>
Date:   Wed Jul 30 18:45:15 2014 +0200

    css: Fail animation shorthand parsing properly
    
    When a number is not a nubmer, don't just crash, exit properly with an
    error code.
    
    See attached testcase for an example.

 gtk/gtkcssshorthandpropertyimpl.c                 |    3 +++
 testsuite/css/parser/Makefile.am                  |    3 +++
 testsuite/css/parser/animation-crash-3.12.css     |    3 +++
 testsuite/css/parser/animation-crash-3.12.errors  |    1 +
 4 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c
index c81e2c4..6477878 100644
--- a/gtk/gtkcssshorthandpropertyimpl.c
+++ b/gtk/gtkcssshorthandpropertyimpl.c
@@ -722,6 +722,9 @@ parse_one_animation (GtkCssShorthandProperty  *shorthand,
                                                GTK_CSS_POSITIVE_ONLY
                                                | (values[1] == NULL ? GTK_CSS_PARSE_NUMBER : 0)
                                                | (values[3] == NULL ? GTK_CSS_PARSE_TIME : 0));
+          if (value == NULL)
+            return FALSE;
+
           if (_gtk_css_number_value_get_unit (value) == GTK_CSS_NUMBER)
             values[1] = value;
           else if (values[2] == NULL)
diff --git a/testsuite/css/parser/Makefile.am b/testsuite/css/parser/Makefile.am
index f44f775..4c35afe 100644
--- a/testsuite/css/parser/Makefile.am
+++ b/testsuite/css/parser/Makefile.am
@@ -30,6 +30,9 @@ clean-local:
        rm $(builddir)/*.out.css || true
 
 test_data = \
+       animation-crash-3.12.css \
+       animation-crash-3.12.errors \
+       animation-crash-3.12.ref.css \
        animation-shorthand-crash.css \
        animation-shorthand-crash.ref.css \
        at-invalid-01.css \
diff --git a/testsuite/css/parser/animation-crash-3.12.css b/testsuite/css/parser/animation-crash-3.12.css
new file mode 100644
index 0000000..c9f4506
--- /dev/null
+++ b/testsuite/css/parser/animation-crash-3.12.css
@@ -0,0 +1,3 @@
+* {
+  animation: 2gra;
+}
diff --git a/testsuite/css/parser/animation-crash-3.12.errors 
b/testsuite/css/parser/animation-crash-3.12.errors
new file mode 100644
index 0000000..8c9ecc4
--- /dev/null
+++ b/testsuite/css/parser/animation-crash-3.12.errors
@@ -0,0 +1 @@
+animation-crash-3.12.css:2: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
diff --git a/testsuite/css/parser/animation-crash-3.12.ref.css 
b/testsuite/css/parser/animation-crash-3.12.ref.css
new file mode 100644
index 0000000..e69de29


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