css: Avoid a crash with relative colors

rgba(from @foo ...) would crash if @foo was not a named color.
Handle it as we do elsewhere, by returning NULL from resolve().

Test included.

Fixes: #6985
This commit is contained in:
Matthias Clasen 2024-09-05 22:21:03 -04:00
parent b6d19f4c8b
commit 3f7f9b705e
4 changed files with 27 additions and 0 deletions

View File

@ -700,6 +700,8 @@ gtk_css_color_value_do_resolve (GtkCssValue *color,
GtkCssValue *vals[4]; GtkCssValue *vals[4];
origin = gtk_css_color_value_do_resolve (color->relative.origin, context, current, cycle_list); origin = gtk_css_color_value_do_resolve (color->relative.origin, context, current, cycle_list);
if (origin == NULL)
return NULL;
for (guint i = 0; i < 4; i++) for (guint i = 0; i < 4; i++)
{ {

View File

@ -0,0 +1,3 @@
label {
color: oklab(from @foo max(l, 0.75) a b / alpha);
}

View File

@ -0,0 +1,4 @@
window.background:dir(ltr)
box.horizontal:dir(ltr)
label:dir(ltr)
color: rgb(255,255,255); /* bad-relative-color.css:2:3-52 */

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="decorated">0</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Hello World!</property>
</object>
</child>
</object>
</child>
</object>
</interface>