changeset 23134:26824776adf6 v8.2.2113

patch 8.2.2113: MS-Windows GUI: crash after using ":set guifont=" four times Commit: https://github.com/vim/vim/commit/1b3e0727ce86ca4cfa47f8b5421d82ed47a9bec1 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Dec 8 21:12:40 2020 +0100 patch 8.2.2113: MS-Windows GUI: crash after using ":set guifont=" four times Problem: MS-Windows GUI: crash after using ":set guifont=" four times. Solution: Check for NULL pointer. (Ken Takata, closes https://github.com/vim/vim/issues/7434)
author Bram Moolenaar <Bram@vim.org>
date Tue, 08 Dec 2020 21:15:03 +0100
parents 6d5bc7eb0e86
children 77a756d54bbf
files src/gui_dwrite.cpp src/testdir/test_gui.vim src/version.c
diffstat 3 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/gui_dwrite.cpp
+++ b/src/gui_dwrite.cpp
@@ -239,7 +239,8 @@ public:
 	if (mItems[n].pTextFormat != item.pTextFormat)
 	{
 	    SafeRelease(&mItems[n].pTextFormat);
-	    item.pTextFormat->AddRef();
+	    if (item.pTextFormat != NULL)
+		item.pTextFormat->AddRef();
 	}
 	mItems[n] = item;
 	slide(n);
--- a/src/testdir/test_gui.vim
+++ b/src/testdir/test_gui.vim
@@ -386,6 +386,13 @@ func Test_set_guifont()
   if has('win32')
     " Invalid font names are accepted in GTK GUI
     call assert_fails('set guifont=xa1bc23d7f', 'E596:')
+
+    " doing this four times used to cause a crash
+    set guifont=
+    set guifont=
+    set guifont=
+    set guifont=
+    set guifont=
   endif
 
   if has('xfontset')
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2113,
+/**/
     2112,
 /**/
     2111,