gl renderer: Avoid an invalid read

We need to copy the color here, since the program state can live across
frame boundaries.
This commit is contained in:
Timm Bäder 2019-12-17 13:06:02 +01:00
parent 2079c898e7
commit 73f2167fe4
2 changed files with 6 additions and 8 deletions

View File

@ -617,11 +617,10 @@ ops_set_color (RenderOpBuilder *builder,
ProgramState *current_program_state = get_current_program_state (builder); ProgramState *current_program_state = get_current_program_state (builder);
OpColor *op; OpColor *op;
if (current_program_state->color && if (gdk_rgba_equal (color, &current_program_state->color))
gdk_rgba_equal (color, current_program_state->color))
return; return;
current_program_state->color = color; current_program_state->color = *color;
op = ops_begin (builder, OP_CHANGE_COLOR); op = ops_begin (builder, OP_CHANGE_COLOR);
op->rgba = color; op->rgba = color;
@ -696,14 +695,13 @@ ops_set_border_color (RenderOpBuilder *builder,
ProgramState *current_program_state = get_current_program_state (builder); ProgramState *current_program_state = get_current_program_state (builder);
OpBorder *op; OpBorder *op;
if (current_program_state->border.color && if (gdk_rgba_equal (color, &current_program_state->border.color))
gdk_rgba_equal (color, current_program_state->border.color))
return; return;
op = op_buffer_add (&builder->render_ops, OP_CHANGE_BORDER_COLOR); op = op_buffer_add (&builder->render_ops, OP_CHANGE_BORDER_COLOR);
op->color = color; op->color = color;
current_program_state->border.color = color; current_program_state->border.color = *color;
} }
void void

View File

@ -112,14 +112,14 @@ typedef struct
float opacity; float opacity;
/* Per-program state */ /* Per-program state */
union { union {
const GdkRGBA *color; GdkRGBA color;
struct { struct {
graphene_matrix_t matrix; graphene_matrix_t matrix;
graphene_vec4_t offset; graphene_vec4_t offset;
} color_matrix; } color_matrix;
struct { struct {
float widths[4]; float widths[4];
const GdkRGBA *color; GdkRGBA color;
GskRoundedRect outline; GskRoundedRect outline;
} border; } border;
}; };