foxygit / doom Log in
commit 66453953e85ef131b3018e15fb22b9070f9f2826
Author:     Roman Fomin <rfomin@gmail.com>
AuthorDate: Mon Nov 20 14:24:23 2023 +0700
Commit:     GitHub <noreply@github.com>
CommitDate: Mon Nov 20 08:24:23 2023 +0100

    win midi: Fix crash in the sound menu of the setup without config (#1642)
---
 src/i_winmusic.c  | 5 +++++
 src/setup/sound.c | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/src/i_winmusic.c b/src/i_winmusic.c
index 6985b8bb..910a8f59 100644
--- a/src/i_winmusic.c
+++ b/src/i_winmusic.c
@@ -1553,6 +1553,11 @@ static boolean I_WIN_InitMusic(void)
     int i;
     MMRESULT mmr;

+    if (winmm_midi_device == NULL)
+    {
+        winmm_midi_device = M_StringDuplicate("");
+    }
+
     for (i = 0; i < all_devices; i++)
     {
         MIDIOUTCAPS caps;
diff --git a/src/setup/sound.c b/src/setup/sound.c
index d79fd49c..885f3505 100644
--- a/src/setup/sound.c
+++ b/src/setup/sound.c
@@ -373,6 +373,10 @@ void BindSoundVariables(void)
     timidity_cfg_path = M_StringDuplicate("");
     gus_patch_path = M_StringDuplicate("");

+#ifdef _WIN32
+    winmm_midi_device = M_StringDuplicate("");
+#endif
+
 #ifdef HAVE_FLUIDSYNTH
     fsynth_sf_path = M_StringDuplicate("");
 #endif