]> granicus.if.org Git - vim/commitdiff
patch 8.2.2113: MS-Windows GUI: crash after using ":set guifont=" four times v8.2.2113
authorBram Moolenaar <Bram@vim.org>
Tue, 8 Dec 2020 20:12:40 +0000 (21:12 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 8 Dec 2020 20:12:40 +0000 (21:12 +0100)
Problem:    MS-Windows GUI: crash after using ":set guifont=" four times.
Solution:   Check for NULL pointer. (Ken Takata, closes #7434)

src/gui_dwrite.cpp
src/testdir/test_gui.vim
src/version.c

index 8767dc1af9c2c1032c1345862f59e4deb4c6c2d7..83acdab1ad959647c922ddf70e79178442b532ff 100644 (file)
@@ -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);
index 89ec3a912ef451b78af21c5bdc41062955f24f22..6d750e0217377c051cf492ab947404fa12bc1a48 100644 (file)
@@ -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')
index f4415817bddd17e652a5ebbe5add7bda4d441a65..75590690def04a948f5b5662dd27c686dfb937ea 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2113,
 /**/
     2112,
 /**/