summaryrefslogtreecommitdiff
path: root/gtk/gtktextiter.c
diff options
context:
space:
mode:
authorOrivej Desh <orivej@gmx.fr>2018-12-16 17:03:47 +0000
committerOrivej Desh <orivej@gmx.fr>2018-12-16 17:03:47 +0000
commit3ec2d5fa382534a7021baa05163011e0401ace56 (patch)
treebb3aaea117f4561e04699edc0d50dd6d69fec65c /gtk/gtktextiter.c
parenta0b5b39bbd096f869a7b4fa27538c43c6800a031 (diff)
downloadgtk+-3ec2d5fa382534a7021baa05163011e0401ace56.tar.gz
Zero-fill new GtkTextIter
iter_init_common() is used on uninitialized GtkTextIter, and since neither it nor its callers initiliaze its padding fields, they contain garbage. This is a problem for Go - which checks that structs passed to C functions do not contain pointers to Go-allocated memory - when the garbage happens to be such a pointer. Although Go zero-fills all GtkTextIter that it allocates, this does not help when GTK functions such as insert_pixbuf_or_widget_segment called for gtk_text_buffer_create_child_anchor copy garbage from their stack-allocated GtkTextIter into a clean iter. To work around this a GtkTextIter has to be discraded after use in text buffer anchor inserting functions: https://github.com/gotk3/gotk3/pull/307
Diffstat (limited to 'gtk/gtktextiter.c')
-rw-r--r--gtk/gtktextiter.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c
index e16f3a5796..be31d084d0 100644
--- a/gtk/gtktextiter.c
+++ b/gtk/gtktextiter.c
@@ -245,6 +245,8 @@ iter_init_common (GtkTextIter *_iter,
g_return_val_if_fail (iter != NULL, NULL);
g_return_val_if_fail (tree != NULL, NULL);
+ memset (iter, 0, sizeof (GtkTextRealIter));
+
iter->tree = tree;
iter->chars_changed_stamp =