From 2bad613cb07bafc7bc4d22f9992562fa5bc831e1 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 18 May 2019 16:20:39 +0200 Subject: [PATCH] text: Ensure indexes are ordered properly --- gtk/gtktext.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gtk/gtktext.c b/gtk/gtktext.c index f026ead3ae..49e1271568 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -2260,7 +2260,11 @@ gtk_text_get_pixel_ranges (GtkText *self, int end_index = g_utf8_offset_to_pointer (text, priv->current_pos) - text; int real_n_ranges, i; - pango_layout_line_get_x_ranges (line, start_index, end_index, ranges, &real_n_ranges); + pango_layout_line_get_x_ranges (line, + MIN (start_index, end_index), + MAX (start_index, end_index), + ranges, + &real_n_ranges); if (ranges) {