[gtk/gtk-3-24] Zero-fill new GtkTextIter



commit f6bc2415ab47eab96dd2c12be3792eff4a0de709
Author: Orivej Desh <orivej gmx fr>
Date:   Sun Dec 16 17:03:47 2018 +0000

    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

 gtk/gtktextiter.c | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c
index cecee72862..ee607919d4 100644
--- a/gtk/gtktextiter.c
+++ b/gtk/gtktextiter.c
@@ -246,6 +246,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 =


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]