Merge lp:~dandrader/geis/lp1080386 into lp:geis

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Stephen M. Webb
Approved revision: 300
Merged at revision: 299
Proposed branch: lp:~dandrader/geis/lp1080386
Merge into: lp:geis
Diff against target: 79 lines (+43/-2)
4 files modified
debian/changelog (+6/-0)
libgeis/geis_filter.c (+1/-1)
testsuite/geis2/Makefile.am (+2/-1)
testsuite/geis2/gtest_gbe_null_filter.cpp (+34/-0)
To merge this branch: bzr merge lp:~dandrader/geis/lp1080386
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+138816@code.launchpad.net

Commit message

Don't crash if a null filter is passed to geis_filter_delete()

Just as the following doesn't lead to a crash:
  int *foo = nullptr;
  delete foo;

Fixes lp:1080386

Description of the change

Fixes bug 1080386.

As I cannot really reproduce the bug by "natural" means, I tried it out on my test laptop by hardcoding geis_subscription_activate() to fail and it indeed a crash just like the one reported happens. Applying the this patches fixed it.

To post a comment you must log in.
Revision history for this message
Stephen M. Webb (bregma) wrote :

OK

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-12-05 02:01:14 +0000
3+++ debian/changelog 2012-12-07 19:08:20 +0000
4@@ -1,3 +1,9 @@
5+geis (2.2.15) UNRELEASED; urgency=low
6+
7+ * Don't crash if a null filter is passed to geis_filter_delete() (LP: #1080386)
8+
9+ -- Daniel d'Andrada <daniel.dandrada@canonical.com> Fri, 07 Dec 2012 16:44:58 -0200
10+
11 geis (2.2.15daily12.12.05-0ubuntu1) raring; urgency=low
12
13 [ Stephen M. Webb ]
14
15=== modified file 'libgeis/geis_filter.c'
16--- libgeis/geis_filter.c 2012-12-04 12:39:16 +0000
17+++ libgeis/geis_filter.c 2012-12-07 19:08:20 +0000
18@@ -361,7 +361,7 @@
19 {
20 GeisStatus status = GEIS_STATUS_SUCCESS;
21
22- if (geis_filter_unref(filter) == 0)
23+ if (filter && (geis_filter_unref(filter) == 0))
24 {
25 geis_unref(filter->geis);
26 geis_backend_token_delete(filter->backend_token);
27
28=== modified file 'testsuite/geis2/Makefile.am'
29--- testsuite/geis2/Makefile.am 2012-09-05 14:42:06 +0000
30+++ testsuite/geis2/Makefile.am 2012-12-07 19:08:20 +0000
31@@ -52,7 +52,8 @@
32 gtest_gbe_deactivate_sub.cpp \
33 gtest_gbe_direct_touch_coords.cpp \
34 gtest_gbe_construction_finished.cpp \
35- gtest_gbe_outdated_events.cpp
36+ gtest_gbe_outdated_events.cpp \
37+ gtest_gbe_null_filter.cpp
38
39 gtest_geis2_grail_backend_CPPFLAGS = \
40 --std=c++0x \
41
42=== added file 'testsuite/geis2/gtest_gbe_null_filter.cpp'
43--- testsuite/geis2/gtest_gbe_null_filter.cpp 1970-01-01 00:00:00 +0000
44+++ testsuite/geis2/gtest_gbe_null_filter.cpp 2012-12-07 19:08:20 +0000
45@@ -0,0 +1,34 @@
46+#include "gtest_grail_backend.h"
47+#include "x11_mocks.h"
48+
49+/*
50+ Checks trying to delete a null filter doesn't cause problems.
51+
52+ Regression test for https://bugs.launchpad.net/nux/+bug/1080386
53+ */
54+
55+class DeleteNullFilter : public Geis2GrailBackendBase
56+{
57+ protected:
58+ virtual void OnEventInitComplete(GeisEvent event);
59+};
60+
61+void DeleteNullFilter::OnEventInitComplete(GeisEvent event)
62+{
63+ GeisFilter filter = nullptr;
64+ geis_filter_delete(filter); // please don't crash
65+}
66+
67+TEST_F(DeleteNullFilter, Test)
68+{
69+ CreateXMockTouchScreenDevice();
70+
71+ _geis = geis_new(GEIS_INIT_GRAIL_BACKEND,
72+ GEIS_INIT_NO_ATOMIC_GESTURES,
73+ nullptr);
74+ ASSERT_NE(nullptr, _geis);
75+
76+ Run();
77+
78+ DestroyXMockDevices();
79+}

Subscribers

People subscribed via source and target branches