[gimp] Issue #3304 - Invalid write when halting filter tool with controller
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Issue #3304 - Invalid write when halting filter tool with controller
- Date: Tue, 30 Apr 2019 20:47:46 +0000 (UTC)
commit 068df34a273aa5542f854e1c627386c6f2ad7750
Author: Ell <ell_se yahoo com>
Date: Tue Apr 30 16:41:43 2019 -0400
Issue #3304 - Invalid write when halting filter tool with controller
In GimpFilterTool, properly clean up the controller's widget weak-
pointer and signal-handlers upon destruction, to avoid invalid
memory access when the widget is destroyed, if the widget outlives
the controller.
app/tools/gimpfiltertool-widgets.c | 113 ++++++++++++++++++++++---------------
1 file changed, 68 insertions(+), 45 deletions(-)
---
diff --git a/app/tools/gimpfiltertool-widgets.c b/app/tools/gimpfiltertool-widgets.c
index f9de579301..051679c320 100644
--- a/app/tools/gimpfiltertool-widgets.c
+++ b/app/tools/gimpfiltertool-widgets.c
@@ -56,48 +56,51 @@ struct _Controller
/* local function prototypes */
-static void gimp_filter_tool_set_line (Controller *controller,
- GeglRectangle *area,
- gdouble x1,
- gdouble y1,
- gdouble x2,
- gdouble y2);
-static void gimp_filter_tool_line_changed (GimpToolWidget *widget,
- Controller *controller);
-
-static void gimp_filter_tool_set_slider_line (Controller *controller,
- GeglRectangle *area,
- gdouble x1,
- gdouble y1,
- gdouble x2,
- gdouble y2,
- const GimpControllerSlider *sliders,
- gint n_sliders);
-static void gimp_filter_tool_slider_line_changed (GimpToolWidget *widget,
- Controller *controller);
-
-static void gimp_filter_tool_set_transform_grid (Controller *controller,
- GeglRectangle *area,
- const GimpMatrix3 *transform);
-static void gimp_filter_tool_transform_grid_changed (GimpToolWidget *widget,
- Controller *controller);
-
-static void gimp_filter_tool_set_transform_grids (Controller *controller,
- GeglRectangle *area,
- const GimpMatrix3 *transforms,
- gint n_transforms);
-static void gimp_filter_tool_transform_grids_changed (GimpToolWidget *widget,
- Controller *controller);
-
-static void gimp_filter_tool_set_gyroscope (Controller *controller,
- GeglRectangle *area,
- gdouble yaw,
- gdouble pitch,
- gdouble roll,
- gdouble zoom,
- gboolean invert);
-static void gimp_filter_tool_gyroscope_changed (GimpToolWidget *widget,
- Controller *controller);
+static Controller * gimp_filter_tool_controller_new (void);
+static void gimp_filter_tool_controller_free (Controller *controller);
+
+static void gimp_filter_tool_set_line (Controller *controller,
+ GeglRectangle *area,
+ gdouble x1,
+ gdouble y1,
+ gdouble x2,
+ gdouble y2);
+static void gimp_filter_tool_line_changed (GimpToolWidget *widget,
+ Controller *controller);
+
+static void gimp_filter_tool_set_slider_line (Controller *controller,
+ GeglRectangle *area,
+ gdouble x1,
+ gdouble y1,
+ gdouble x2,
+ gdouble y2,
+ const GimpControllerSlider *sliders,
+ gint n_sliders);
+static void gimp_filter_tool_slider_line_changed (GimpToolWidget *widget,
+ Controller *controller);
+
+static void gimp_filter_tool_set_transform_grid (Controller *controller,
+ GeglRectangle *area,
+ const GimpMatrix3 *transform);
+static void gimp_filter_tool_transform_grid_changed (GimpToolWidget *widget,
+ Controller *controller);
+
+static void gimp_filter_tool_set_transform_grids (Controller *controller,
+ GeglRectangle *area,
+ const GimpMatrix3 *transforms,
+ gint n_transforms);
+static void gimp_filter_tool_transform_grids_changed (GimpToolWidget *widget,
+ Controller *controller);
+
+static void gimp_filter_tool_set_gyroscope (Controller *controller,
+ GeglRectangle *area,
+ gdouble yaw,
+ gdouble pitch,
+ gdouble roll,
+ gdouble zoom,
+ gboolean invert);
+static void gimp_filter_tool_gyroscope_changed (GimpToolWidget *widget,
+ Controller *controller);
/* public functions */
@@ -124,7 +127,7 @@ gimp_filter_tool_create_widget (GimpFilterTool *filter_tool,
shell = gimp_display_get_shell (tool->display);
- controller = g_new0 (Controller, 1);
+ controller = gimp_filter_tool_controller_new ();
controller->filter_tool = filter_tool;
controller->controller_type = controller_type;
@@ -246,11 +249,11 @@ gimp_filter_tool_create_widget (GimpFilterTool *filter_tool,
}
g_object_add_weak_pointer (G_OBJECT (controller->widget),
- (gpointer) &controller->widget);
+ (gpointer) &controller->widget);
g_object_set_data_full (filter_tool->config,
"gimp-filter-tool-controller", controller,
- (GDestroyNotify) g_free);
+ (GDestroyNotify) gimp_filter_tool_controller_free);
return controller->widget;
}
@@ -346,6 +349,26 @@ gimp_filter_tool_reset_widget (GimpFilterTool *filter_tool,
/* private functions */
+static Controller *
+gimp_filter_tool_controller_new (void)
+{
+ return g_slice_new0 (Controller);
+}
+
+static void
+gimp_filter_tool_controller_free (Controller *controller)
+{
+ if (controller->widget)
+ {
+ g_signal_handlers_disconnect_by_data (controller->widget, controller);
+
+ g_object_remove_weak_pointer (G_OBJECT (controller->widget),
+ (gpointer) &controller->widget);
+ }
+
+ g_slice_free (Controller, controller);
+}
+
static void
gimp_filter_tool_set_line (Controller *controller,
GeglRectangle *area,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]