# HG changeset patch # User Bram Moolenaar # Date 1607458503 -3600 # Node ID 26824776adf6de680d8f8adb2340a510016273a5 # Parent 6d5bc7eb0e8659e165dac84fb8fa0c7b9648d902 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 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) diff --git a/src/gui_dwrite.cpp b/src/gui_dwrite.cpp --- 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); diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim --- 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') diff --git a/src/version.c b/src/version.c --- 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,