summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Ã…dahl <jadahl@gmail.com>2021-02-24 16:39:42 +0100
committerMarge Bot <marge-bot@gnome.org>2021-02-24 15:59:58 +0000
commit3bbfaa03b3944a856540eaca00f76f3975e09cfd (patch)
treeb3f1600ddcd088c0b38bcca6f40f6808d5ff9661
parentbec456ba0a3a9aa54c09052c0b1591b4b81e1ed5 (diff)
downloadmutter-3bbfaa03b3944a856540eaca00f76f3975e09cfd.tar.gz
background-content: Fix pipeline cache size
The cache had the size 9, which was "big enough" in the past, but when more ways pipelines could be constructed, the size was not enough. The need to increase the cache size was hard to spot though, since adding pipeline flag didn't give any hints about the cache being directly tied to these flag values. So, when enough flag bits were set when attempting to retrieve and put a pipeline in the cache, it'd instead overwrite some arbitrary stack memory, which would sooner or later result in a memory corruption induced crash. Valgrind could not detect this particular memory corruption, as it messed up stack memory, not e.g. freed heap memory, so it instead got confused and thought plain stack values were unreadable. Fix these two issues by making the cache size the combination of all pipeline flags + 1, so that we can safely put any flag combination in the cache. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1747>
-rw-r--r--src/compositor/meta-background-content.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/compositor/meta-background-content.c b/src/compositor/meta-background-content.c
index 5031c8969..73db45440 100644
--- a/src/compositor/meta-background-content.c
+++ b/src/compositor/meta-background-content.c
@@ -218,6 +218,11 @@ typedef enum
PIPELINE_BLEND = (1 << 1),
PIPELINE_GRADIENT = (1 << 2),
PIPELINE_ROUNDED_CLIP = (1 << 3),
+
+ PIPELINE_ALL = (PIPELINE_VIGNETTE |
+ PIPELINE_BLEND |
+ PIPELINE_GRADIENT |
+ PIPELINE_ROUNDED_CLIP)
} PipelineFlags;
struct _MetaBackgroundContent
@@ -324,9 +329,11 @@ on_background_changed (MetaBackground *background,
static CoglPipeline *
make_pipeline (PipelineFlags pipeline_flags)
{
- static CoglPipeline *templates[9];
+ static CoglPipeline *templates[PIPELINE_ALL + 1];
CoglPipeline **templatep;
+ g_assert (pipeline_flags < G_N_ELEMENTS (templates));
+
templatep = &templates[pipeline_flags];
if (*templatep == NULL)
{