cssimagecrossfade: Don't abort() when failing to parse image

The code wasn't checking if parsing an image failed and just returning
success.

Testcase from bug is attached.

Fixes #4101


(cherry picked from commit a76f515569)
This commit is contained in:
Benjamin Otte 2021-07-16 17:48:25 +02:00 committed by Benjamin Otte
parent 82b2558e46
commit a5b1a86ab7
5 changed files with 18 additions and 5 deletions

View File

@ -312,7 +312,13 @@ parse_image (GtkCssParser *parser,
GtkCssImage **image = option_data;
if (_gtk_css_image_can_parse (parser))
*image = _gtk_css_image_new_parse (parser);
{
*image = _gtk_css_image_new_parse (parser);
if (*image == NULL)
return FALSE;
return TRUE;
}
else if (gtk_css_color_value_can_parse (parser))
{
GtkCssValue *color;
@ -322,11 +328,11 @@ parse_image (GtkCssParser *parser,
return FALSE;
*image = _gtk_css_image_fallback_new_for_color (color);
}
else
return FALSE;
return TRUE;
return TRUE;
}
return FALSE;
}
static guint

View File

@ -0,0 +1,3 @@
a {
background: cross-fade(8% -gtk-icontheme("system-run-symbolic"), image());
}

View File

@ -0,0 +1 @@
cross-fade-crash-4101.css:2:74-75: error: GTK_CSS_PARSER_ERROR_SYNTAX

View File

@ -212,6 +212,9 @@ test_data = [
'comment-detection.css',
'comment-detection.ref.css',
'cross-fade-basic.css',
'cross-fade-crash-4101.css',
'cross-fade-crash-4101.errors',
'cross-fade-crash-4101.ref.css',
'css-21-malformed-declarations.css',
'css-21-malformed-declarations.errors',
'css-21-malformed-declarations.ref.css',