Debian Codegraph @

debian/patches/clutter-master-clock-gdk-Do-not-try-to-access-invalidated.patch

raw
1 From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <[email protected]>
2 Date: Wed, 8 Mar 2023 17:45:29 +0100
3 Subject: clutter-master-clock-gdk: Do not try to access invalidated list
4
5 During a stage update a stage could be removed, this was handled only once
6 and when it happened we did not care about updating the list of of stages
7 we're going through, with possible access to invalid or free'd memory.
8
9 So we while iterating and after processing the events we need to check if a
10 stage is still valid, if that's the case we just continue in the normal way
11 otherwise we ignore further stage operations and we fetch again the list
12 we're iterating on, in case that has changed.
13
14 See: https://autopkgtest.ubuntu.com/results/autopkgtest-lunar/lunar/amd64/c/clutter-1.0/20230308_084252_929ac@/log.gz
15 ---
16 clutter/gdk/clutter-master-clock-gdk.c | 19 ++++++++++++++++---
17 1 file changed, 16 insertions(+), 3 deletions(-)
18
19 diff --git a/clutter/gdk/clutter-master-clock-gdk.c b/clutter/gdk/clutter-master-clock-gdk.c
20 index 90c4cce..b9e60ca 100644
21 --- a/clutter/gdk/clutter-master-clock-gdk.c
22 +++ b/clutter/gdk/clutter-master-clock-gdk.c
23 @@ -264,7 +264,7 @@ static void
24 clutter_master_clock_gdk_update (GdkFrameClock *frame_clock,
25 ClutterMasterClockGdk *master_clock)
26 {
27 - GList *stages, *l;
28 + GList *stages, *l, *next;
29
30 _clutter_threads_acquire_lock ();
31
32 @@ -279,7 +279,7 @@ clutter_master_clock_gdk_update (GdkFrameClock *frame_clock,
33 stages = g_hash_table_lookup (master_clock->clock_to_stage, frame_clock);
34 CLUTTER_NOTE (SCHEDULER, "Updating %d stages tied to frame clock %p",
35 g_list_length (stages), frame_clock);
36 - for (l = stages; l != NULL; l = l->next)
37 + for (l = stages; l != NULL; l = next)
38 {
39 ClutterStage *stage = l->data;
40
41 @@ -304,7 +304,20 @@ clutter_master_clock_gdk_update (GdkFrameClock *frame_clock,
42 if (g_hash_table_lookup (master_clock->stage_to_clock, stage) != NULL)
43 {
44 master_clock_update_stage (master_clock, stage);
45 - master_clock_schedule_stage_update (master_clock, stage, frame_clock);
46 +
47 + if (g_hash_table_lookup (master_clock->stage_to_clock, stage) != NULL)
48 + {
49 + master_clock_schedule_stage_update (master_clock, stage, frame_clock);
50 + next = l->next;
51 + }
52 + else
53 + {
54 + next = g_hash_table_lookup (master_clock->clock_to_stage, frame_clock);
55 + }
56 + }
57 + else
58 + {
59 + next = g_hash_table_lookup (master_clock->clock_to_stage, frame_clock);
60 }
61 }
62