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
=== modified file 'libgeis/geis_subscription.c'
--- libgeis/geis_subscription.c 2012-09-05 14:59:39 +0000
+++ libgeis/geis_subscription.c 2012-11-13 02:57:18 +0000
@@ -337,6 +337,7 @@
337 if (sub->sub_backend_token)337 if (sub->sub_backend_token)
338 {338 {
339 status = geis_backend_token_deactivate(sub->sub_backend_token, sub);339 status = geis_backend_token_deactivate(sub->sub_backend_token, sub);
340 sub->sub_backend_token = NULL;
340 }341 }
341 return status;342 return status;
342}343}
343344
=== modified file 'libgeis/geis_v1.c'
--- libgeis/geis_v1.c 2012-07-24 16:04:12 +0000
+++ libgeis/geis_v1.c 2012-11-13 02:57:18 +0000
@@ -619,19 +619,7 @@
619 {619 {
620 const char **g;620 const char **g;
621621
622 if (device_id != 0)622 geis_debug("subscribing device %d for the following gestures:", device_id);
623 {
624 geis_debug("subscribing device %d for the following gestures:", device_id);
625 result = geis_filter_add_term(instance->window_filter,
626 GEIS_FILTER_DEVICE,
627 GEIS_DEVICE_ATTRIBUTE_ID, GEIS_FILTER_OP_EQ,
628 device_id, NULL);
629 if (result != GEIS_STATUS_SUCCESS)
630 {
631 geis_error("error adding device filter term");
632 }
633 }
634
635 for (g = gesture_list; *g; ++g)623 for (g = gesture_list; *g; ++g)
636 {624 {
637 GeisV1AttrMap v1attr;625 GeisV1AttrMap v1attr;
@@ -664,6 +652,17 @@
664 geis_error("error adding gesture class filter term");652 geis_error("error adding gesture class filter term");
665 }653 }
666654
655 if (device_id != 0)
656 {
657 result = geis_filter_add_term(filter,
658 GEIS_FILTER_DEVICE, GEIS_DEVICE_ATTRIBUTE_ID, GEIS_FILTER_OP_EQ,
659 device_id, NULL);
660 if (result != GEIS_STATUS_SUCCESS)
661 {
662 geis_error("error adding device filter term");
663 }
664 }
665
667 result = geis_subscription_add_filter(instance->subscription, filter); 666 result = geis_subscription_add_filter(instance->subscription, filter);
668 if (result != GEIS_STATUS_SUCCESS)667 if (result != GEIS_STATUS_SUCCESS)
669 {668 {
@@ -674,14 +673,6 @@
674 }673 }
675 }674 }
676 }675 }
677
678 /* remove the window-id-only filter since it allows ALL gesture classes */
679 result = geis_subscription_remove_filter(instance->subscription,
680 instance->window_filter);
681 if (result != GEIS_STATUS_SUCCESS)
682 {
683 geis_warning("error removing V1 window filter");
684 }
685 }676 }
686 return result;677 return result;
687}678}
@@ -696,6 +687,16 @@
696{687{
697 GeisStatus result = GEIS_UNKNOWN_ERROR;688 GeisStatus result = GEIS_UNKNOWN_ERROR;
698689
690 /**
691 * If there is no window filter, the instance has already been subscribed to
692 * devices and gestures so skip.
693 */
694 if (NULL == instance->window_filter)
695 {
696 geis_warning("instance has been subscribed twice");
697 return GEIS_STATUS_SUCCESS;
698 }
699
699 memcpy(&instance->gesture_funcs, funcs, sizeof(GeisGestureFuncs));700 memcpy(&instance->gesture_funcs, funcs, sizeof(GeisGestureFuncs));
700 instance->gesture_cookie = cookie;701 instance->gesture_cookie = cookie;
701702
@@ -719,6 +720,23 @@
719 }720 }
720 }721 }
721 }722 }
723
724 /*
725 * If there are specific gesture classes, remove the window-id-only filter since it allows
726 * ALL gesture classes. It will have been replaced by device-specific or
727 * class-specific filters on the same window.
728 */
729 if (gesture_list && *gesture_list)
730 {
731 result = geis_subscription_remove_filter(instance->subscription,
732 instance->window_filter);
733 if (result != GEIS_STATUS_SUCCESS)
734 {
735 geis_warning("error removing V1 window filter");
736 }
737 instance->window_filter = NULL;
738 }
739
722 result = geis_subscription_activate(instance->subscription);740 result = geis_subscription_activate(instance->subscription);
723 return result;741 return result;
724}742}

Subscribers

People subscribed via source and target branches