From: Andreas Henriksson <andreas@fatal.se>
Subject: validate returned iterator before passing to get_buffer

This avoids crashing in get_buffer when get_iter returns empty iter.
Unfortunately get_iter doesn't return any indications if it
succeded (and filled the passed reference with useful information)
or failed (and didn't touch the references iter).
An improvement of the gtksourceview API might be useful here.
For now, work around this by knowing that vala will create an
empty iter used as reference to get_iter and then compare it
against another empty iter to know if get_iter succeded or failed.


--- a/src/math-display.vala
+++ b/src/math-display.vala
@@ -450,7 +450,14 @@
 
     public override void populate (Gtk.SourceCompletionContext context)
     {
-        Gtk.TextBuffer text_buffer = context.get_iter ().get_buffer ();
+        Gtk.TextIter emptyiter = {};
+
+        var iter1 = context.get_iter();
+        if (iter1 == emptyiter) {
+            return;
+        }
+
+        Gtk.TextBuffer text_buffer = iter1.get_buffer ();
         MathFunction[] functions = get_matches_for_completion_at_cursor (text_buffer);
 
         List<Gtk.SourceCompletionItem>? proposals = null;
