After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 789149 - GtkGestureZoom leaks the list of sequences while calculating the distance between touch points
GtkGestureZoom leaks the list of sequences while calculating the distance bet...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GtkGesture
3.22.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2017-10-18 14:06 UTC by Debarshi Ray
Modified: 2017-10-19 08:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[gtk-3-22] GtkGestureZoom: Don't leak the list of sequences (1.59 KB, patch)
2017-10-18 14:08 UTC, Debarshi Ray
committed Details | Review
[master] GtkGestureZoom: Don't leak the list of sequences (1.68 KB, patch)
2017-10-18 14:45 UTC, Debarshi Ray
committed Details | Review
[master] GtkGestureZoom: Don't leak the list of sequences (1.68 KB, patch)
2017-10-19 08:28 UTC, Debarshi Ray
committed Details | Review
[gtk-3-22] GtkGestureZoom: Don't leak the list of sequences (1.59 KB, patch)
2017-10-19 08:29 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2017-10-18 14:06:08 UTC
In the unexpected case where an attempt is made to calculate the distance without a sufficient number of event sequences, the list gets leaked.

I am not sure if this can actually happen, but maybe it is a possibility when invoked via gtk_gesture_zoom_get_scale_delta? If it can't happen, then maybe we should turn it into an assertion instead?
Comment 1 Debarshi Ray 2017-10-18 14:08:57 UTC
Created attachment 361805 [details] [review]
[gtk-3-22] GtkGestureZoom: Don't leak the list of sequences

I don't have a touchscreen right now, so this is only compile tested at the moment. I'll test it later when I have my other laptop.
Comment 2 Debarshi Ray 2017-10-18 14:45:41 UTC
Created attachment 361808 [details] [review]
[master] GtkGestureZoom: Don't leak the list of sequences
Comment 3 Carlos Garnacho 2017-10-18 15:19:34 UTC
Review of attachment 361805 [details] [review]:

Nice catch! I have a comment that applies to both patches, feel free to push after fixing locally.

::: gtk/gtkgesturezoom.c
@@ +110,2 @@
       gtk_gesture_get_point (gesture, sequences->data, &x1, &y1);
       gtk_gesture_get_point (gesture, sequences->next->data, &x2, &y2);

Patch context doesn't show it, but there's a g_list_free (sequences) call right below these calls that should now be removed if we are handling it at the end of the function.
Comment 4 Debarshi Ray 2017-10-19 08:28:22 UTC
Created attachment 361843 [details] [review]
[master] GtkGestureZoom: Don't leak the list of sequences
Comment 5 Debarshi Ray 2017-10-19 08:29:32 UTC
Created attachment 361844 [details] [review]
[gtk-3-22] GtkGestureZoom: Don't leak the list of sequences
Comment 6 Debarshi Ray 2017-10-19 08:31:08 UTC
(In reply to Carlos Garnacho from comment #3)
> Review of attachment 361805 [details] [review] [review]:

Thanks for taking a look!

> ::: gtk/gtkgesturezoom.c
> @@ +110,2 @@
>        gtk_gesture_get_point (gesture, sequences->data, &x1, &y1);
>        gtk_gesture_get_point (gesture, sequences->next->data, &x2, &y2);
> 
> Patch context doesn't show it, but there's a g_list_free (sequences) call
> right below these calls that should now be removed if we are handling it at
> the end of the function.

Oops, sorry about that. I fixed that and tested them both on a touchscreen - gtk4-demo for master, and gnome-photos for gtk-3-22.