Blame 0002-cogl-pipeline-Don-t-try-to-access-to-free-d-pointer-.patch

4c22184
From 8d936a410cc10c57b7c0071f85a23997653d4281 Mon Sep 17 00:00:00 2001
4c22184
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
4c22184
Date: Fri, 17 May 2019 19:35:46 +0000
4c22184
Subject: [PATCH 02/28] cogl/pipeline: Don't try to access to free'd pointer
4c22184
 data
4c22184
4c22184
When free'ing a pipeline we destroy the BigState first and then the fragment and
4c22184
vertex snippets lists using the big state pointer which is now invalid.
4c22184
This causes a crash  when G_SLICE=always-malloc is set and using MALLOC_CHECK_.
4c22184
4c22184
So, invert the operations by free'ing the snippet lists first, and the big state
4c22184
afterwards.
4c22184
4c22184
https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
4c22184
4c22184
4c22184
(cherry picked from commit 7e0d185120ea116c91a8db60276971d3fecece80)
4c22184
---
4c22184
 cogl/cogl/cogl-pipeline.c | 6 +++---
4c22184
 1 file changed, 3 insertions(+), 3 deletions(-)
4c22184
4c22184
diff --git a/cogl/cogl/cogl-pipeline.c b/cogl/cogl/cogl-pipeline.c
4c22184
index da2d2ce7e..6a77cda7f 100644
4c22184
--- a/cogl/cogl/cogl-pipeline.c
4c22184
+++ b/cogl/cogl/cogl-pipeline.c
4c22184
@@ -492,9 +492,6 @@ _cogl_pipeline_free (CoglPipeline *pipeline)
4c22184
       _cogl_bitmask_destroy (&uniforms_state->changed_mask);
4c22184
     }
4c22184
 
4c22184
-  if (pipeline->differences & COGL_PIPELINE_STATE_NEEDS_BIG_STATE)
4c22184
-    g_slice_free (CoglPipelineBigState, pipeline->big_state);
4c22184
-
4c22184
   if (pipeline->differences & COGL_PIPELINE_STATE_LAYERS)
4c22184
     {
4c22184
       g_list_foreach (pipeline->layer_differences,
4c22184
@@ -508,6 +505,9 @@ _cogl_pipeline_free (CoglPipeline *pipeline)
4c22184
   if (pipeline->differences & COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS)
4c22184
     _cogl_pipeline_snippet_list_free (&pipeline->big_state->fragment_snippets);
4c22184
 
4c22184
+  if (pipeline->differences & COGL_PIPELINE_STATE_NEEDS_BIG_STATE)
4c22184
+    g_slice_free (CoglPipelineBigState, pipeline->big_state);
4c22184
+
4c22184
   g_list_free (pipeline->deprecated_get_layers_list);
4c22184
 
4c22184
   recursively_free_layer_caches (pipeline);
4c22184
-- 
4c22184
2.21.0
4c22184