gl renderer: Avoid an invalid read
authorTimm Bäder <mail@baedert.org>
Tue, 17 Dec 2019 12:06:02 +0000 (13:06 +0100)
committerTimm Bäder <mail@baedert.org>
Tue, 7 Jan 2020 16:27:16 +0000 (17:27 +0100)
We need to copy the color here, since the program state can live across
frame boundaries.

gsk/gl/gskglrenderops.c
gsk/gl/gskglrenderopsprivate.h

index c2df2f6b4c8b53022ca6d63290e273993b7893ce..27b7bb48ac615f93b0bf0593c13abaff99cebe68 100644 (file)
@@ -617,11 +617,10 @@ ops_set_color (RenderOpBuilder *builder,
   ProgramState *current_program_state = get_current_program_state (builder);
   OpColor *op;
 
-  if (current_program_state->color &&
-      gdk_rgba_equal (color, current_program_state->color))
+  if (gdk_rgba_equal (color, &current_program_state->color))
     return;
 
-  current_program_state->color = color;
+  current_program_state->color = *color;
 
   op = ops_begin (builder, OP_CHANGE_COLOR);
   op->rgba = color;
@@ -696,14 +695,13 @@ ops_set_border_color (RenderOpBuilder *builder,
   ProgramState *current_program_state = get_current_program_state (builder);
   OpBorder *op;
 
-  if (current_program_state->border.color &&
-      gdk_rgba_equal (color, current_program_state->border.color))
+  if (gdk_rgba_equal (color, &current_program_state->border.color))
     return;
 
   op = op_buffer_add (&builder->render_ops, OP_CHANGE_BORDER_COLOR);
   op->color = color;
 
-  current_program_state->border.color = color;
+  current_program_state->border.color = *color;
 }
 
 void
index 81c567e831d72b1be80b8c3648459f0cc3bcaa18..216a45704229f50a193538b360eb427fc933ef87 100644 (file)
@@ -112,14 +112,14 @@ typedef struct
   float opacity;
   /* Per-program state */
   union {
-    const GdkRGBA *color;
+    GdkRGBA color;
     struct {
       graphene_matrix_t matrix;
       graphene_vec4_t offset;
     } color_matrix;
     struct {
       float widths[4];
-      const GdkRGBA *color;
+      GdkRGBA color;
       GskRoundedRect outline;
     } border;
   };