--- wildmidi_lib.cpp.orig 2021-12-15 07:39:58.168708000 +0000 +++ wildmidi_lib.cpp 2021-12-15 07:41:17.698486000 +0000 @@ -1321,23 +1321,38 @@ get_patch_data(unsigned short patchid) { struct _patch *search_patch; - std::lock_guard lock(patch_lock); + /* + * Uh, hey, no, sorry pal, you can't use this + * construction here. This function can call itself + * recursively, which means you will recursively + * try to acquire the patch_lock mutex, which is + * not allowed with lock_guard. + */ +/* std::lock_guard lock(patch_lock); */ + + patch_lock.lock(); search_patch = patch[patchid & 0x007F]; if (search_patch == NULL) { + patch_lock.unlock(); return NULL; } while (search_patch) { if (search_patch->patchid == patchid) { + patch_lock.unlock(); return search_patch; } search_patch = search_patch->next; } + + patch_lock.unlock(); + if ((patchid >> 8) != 0) { return (get_patch_data(patchid & 0x00FF)); } + return NULL; } @@ -1380,6 +1395,7 @@ struct _sample *return_sample = NULL; std::lock_guard lock(patch_lock); + if (sample_patch == NULL) { return NULL; }