[gtk] widget: Always set out value
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] widget: Always set out value
- Date: Wed, 20 Feb 2019 04:29:51 +0000 (UTC)
commit 514c3679dc7647db1e64734dab3afc9c9e761e72
Author: Benjamin Otte <otte redhat com>
Date: Wed Feb 20 04:07:34 2019 +0100
widget: Always set out value
Don't leave memory in an unitinialized case when returning FALSE from
gtk_widget_compute_transform().
We both know that people are going to call that function without
checking the return value.
gtk/gtkwidget.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index c3395494ad..21a1ff3333 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -11245,7 +11245,8 @@ gtk_widget_pick (GtkWidget *widget,
*
* Returns: %TRUE if the transform could be computed, %FALSE otherwise.
* The transform can not be computed in certain cases, for example when
- * @widget and @target do not share a common ancestor.
+ * @widget and @target do not share a common ancestor. In that
+ * case @out_transform gets set to the identity matrix.
*/
gboolean
gtk_widget_compute_transform (GtkWidget *widget,
@@ -11268,7 +11269,10 @@ gtk_widget_compute_transform (GtkWidget *widget,
ancestor = gtk_widget_common_ancestor (widget, target);
if (ancestor == NULL)
- return FALSE;
+ {
+ graphene_matrix_init_identity (out_transform);
+ return FALSE;
+ }
graphene_matrix_init_identity (&transform);
for (iter = widget; iter != ancestor; iter = iter->priv->parent)
@@ -11293,7 +11297,10 @@ gtk_widget_compute_transform (GtkWidget *widget,
graphene_matrix_multiply (&inverse, &priv->transform, &inverse);
}
if (!graphene_matrix_inverse (&inverse, &inverse))
- return FALSE;
+ {
+ graphene_matrix_init_identity (out_transform);
+ return FALSE;
+ }
graphene_matrix_multiply (&transform, &inverse, out_transform);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]