[gtk/wip/baedert/gl-rework: 27/29] gl renderer: Avoid an invalid read



commit 9ba70aba206bc08062b2116a029ed93e218ff1fe
Author: Timm Bäder <mail baedert org>
Date:   Tue Dec 17 13:06:02 2019 +0100

    gl renderer: Avoid an invalid read
    
    We need to copy the color here, since the program state can live across
    frame boundaries.

 gsk/gl/gskglrenderops.c        | 10 ++++------
 gsk/gl/gskglrenderopsprivate.h |  4 ++--
 2 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/gsk/gl/gskglrenderops.c b/gsk/gl/gskglrenderops.c
index 9795e249b9..efa092acf0 100644
--- a/gsk/gl/gskglrenderops.c
+++ b/gsk/gl/gskglrenderops.c
@@ -609,11 +609,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;
@@ -690,14 +689,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
diff --git a/gsk/gl/gskglrenderopsprivate.h b/gsk/gl/gskglrenderopsprivate.h
index bd26f9b98f..3d9d81f029 100644
--- a/gsk/gl/gskglrenderopsprivate.h
+++ b/gsk/gl/gskglrenderopsprivate.h
@@ -112,14 +112,14 @@ typedef struct
   float opacity;
   /* Per-program state */
   union {
-    const GdkRGBA *color;
+    GdkRGBA color;
     struct {
       const graphene_matrix_t *matrix;
       const graphene_vec4_t *offset;
     } color_matrix;
     struct {
       float widths[4];
-      const GdkRGBA *color;
+      GdkRGBA color;
       GskRoundedRect outline;
     } border;
   };


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