[gtk] gl renderer: Avoid an invalid read
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] gl renderer: Avoid an invalid read
- Date: Tue, 7 Jan 2020 16:38:03 +0000 (UTC)
commit 73f2167fe46284c42a3975e8477138dd927161cc
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 c2df2f6b4c..27b7bb48ac 100644
--- a/gsk/gl/gskglrenderops.c
+++ b/gsk/gl/gskglrenderops.c
@@ -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, ¤t_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, ¤t_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 81c567e831..216a457042 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 {
graphene_matrix_t matrix;
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]