Merge lp:~bregma/geis/lp-1077376 into lp:geis

Proposed by Stephen M. Webb
Status: Merged
Approved by: Daniel d'Andrada
Approved revision: 288
Merged at revision: 289
Proposed branch: lp:~bregma/geis/lp-1077376
Merge into: lp:geis
Diff against target: 110 lines (+40/-21)
2 files modified
libgeis/geis_subscription.c (+1/-0)
libgeis/geis_v1.c (+39/-21)
To merge this branch: bzr merge lp:~bregma/geis/lp-1077376
Reviewer Review Type Date Requested Status
Daniel d'Andrada (community) Approve
Review via email: mp+134027@code.launchpad.net

Commit message

Avoid dereferencing a freed pointer when more than one V1 gesture class is subscribed (lp: #1077376).

Description of the change

Avoids dereferencing a freed pointer when more than one V1 gesture class is subscribed (lp: #1077376).

No new tests are required: current existing tests were failing and now pass with this fix.

Evince no longer crashes with this fix applied.

To post a comment you must log in.
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Looks ok, although I would be happier to have a regular test to cover this instead of a xorg-gtest one (which is slow and unreliable). I have to confess xorg-gtest-based tests stopped working for me long ago so I didn't bother running them anymore. I just write and check the regular ones.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libgeis/geis_subscription.c'
2--- libgeis/geis_subscription.c 2012-09-05 14:59:39 +0000
3+++ libgeis/geis_subscription.c 2012-11-13 02:57:18 +0000
4@@ -337,6 +337,7 @@
5 if (sub->sub_backend_token)
6 {
7 status = geis_backend_token_deactivate(sub->sub_backend_token, sub);
8+ sub->sub_backend_token = NULL;
9 }
10 return status;
11 }
12
13=== modified file 'libgeis/geis_v1.c'
14--- libgeis/geis_v1.c 2012-07-24 16:04:12 +0000
15+++ libgeis/geis_v1.c 2012-11-13 02:57:18 +0000
16@@ -619,19 +619,7 @@
17 {
18 const char **g;
19
20- if (device_id != 0)
21- {
22- geis_debug("subscribing device %d for the following gestures:", device_id);
23- result = geis_filter_add_term(instance->window_filter,
24- GEIS_FILTER_DEVICE,
25- GEIS_DEVICE_ATTRIBUTE_ID, GEIS_FILTER_OP_EQ,
26- device_id, NULL);
27- if (result != GEIS_STATUS_SUCCESS)
28- {
29- geis_error("error adding device filter term");
30- }
31- }
32-
33+ geis_debug("subscribing device %d for the following gestures:", device_id);
34 for (g = gesture_list; *g; ++g)
35 {
36 GeisV1AttrMap v1attr;
37@@ -664,6 +652,17 @@
38 geis_error("error adding gesture class filter term");
39 }
40
41+ if (device_id != 0)
42+ {
43+ result = geis_filter_add_term(filter,
44+ GEIS_FILTER_DEVICE, GEIS_DEVICE_ATTRIBUTE_ID, GEIS_FILTER_OP_EQ,
45+ device_id, NULL);
46+ if (result != GEIS_STATUS_SUCCESS)
47+ {
48+ geis_error("error adding device filter term");
49+ }
50+ }
51+
52 result = geis_subscription_add_filter(instance->subscription, filter);
53 if (result != GEIS_STATUS_SUCCESS)
54 {
55@@ -674,14 +673,6 @@
56 }
57 }
58 }
59-
60- /* remove the window-id-only filter since it allows ALL gesture classes */
61- result = geis_subscription_remove_filter(instance->subscription,
62- instance->window_filter);
63- if (result != GEIS_STATUS_SUCCESS)
64- {
65- geis_warning("error removing V1 window filter");
66- }
67 }
68 return result;
69 }
70@@ -696,6 +687,16 @@
71 {
72 GeisStatus result = GEIS_UNKNOWN_ERROR;
73
74+ /**
75+ * If there is no window filter, the instance has already been subscribed to
76+ * devices and gestures so skip.
77+ */
78+ if (NULL == instance->window_filter)
79+ {
80+ geis_warning("instance has been subscribed twice");
81+ return GEIS_STATUS_SUCCESS;
82+ }
83+
84 memcpy(&instance->gesture_funcs, funcs, sizeof(GeisGestureFuncs));
85 instance->gesture_cookie = cookie;
86
87@@ -719,6 +720,23 @@
88 }
89 }
90 }
91+
92+ /*
93+ * If there are specific gesture classes, remove the window-id-only filter since it allows
94+ * ALL gesture classes. It will have been replaced by device-specific or
95+ * class-specific filters on the same window.
96+ */
97+ if (gesture_list && *gesture_list)
98+ {
99+ result = geis_subscription_remove_filter(instance->subscription,
100+ instance->window_filter);
101+ if (result != GEIS_STATUS_SUCCESS)
102+ {
103+ geis_warning("error removing V1 window filter");
104+ }
105+ instance->window_filter = NULL;
106+ }
107+
108 result = geis_subscription_activate(instance->subscription);
109 return result;
110 }

Subscribers

People subscribed via source and target branches