diff src/gui_gtk_x11.c @ 26028:be2d004247e1 v8.2.3548

patch 8.2.3548: GTK GUI crashen when reading from stdin Commit: https://github.com/vim/vim/commit/d68a0044858d00de6100def1e389a3a9c1cdbcdc Author: Bram Moolenaar <Bram@vim.org> Date: Wed Oct 20 23:08:11 2021 +0100 patch 8.2.3548: GTK GUI crashen when reading from stdin Problem: GTK GUI crashen when reading from stdin. Solution: Do not overwrite the NUL after the string. (closes https://github.com/vim/vim/issues/9028)
author Bram Moolenaar <Bram@vim.org>
date Thu, 21 Oct 2021 00:15:03 +0200
parents 9b2be5556740
children 5a1850512676
line wrap: on
line diff
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -5744,12 +5744,16 @@ gui_gtk2_draw_string(int row, int col, c
 	    }
 	}
 
-	// temporarily zero terminate substring, print, restore char, wrap
-	backup_ch = *(cs + slen);
-	*(cs + slen) = 0;
+	if (slen < len)
+	{
+	    // temporarily zero terminate substring, print, restore char, wrap
+	    backup_ch = *(cs + slen);
+	    *(cs + slen) = NUL;
+	}
 	len_sum += gui_gtk2_draw_string_ext(row, col + len_sum,
 						 cs, slen, flags, needs_pango);
-	*(cs + slen) = backup_ch;
+	if (slen < len)
+	    *(cs + slen) = backup_ch;
 	cs += slen;
 	byte_sum += slen;
 	needs_pango = should_need_pango;