From b8cd39141958a5850287a612ffa02d81c6f6fe69 Mon Sep 17 00:00:00 2001 From: Jeremy Wentworth Date: Fri, 20 Mar 2026 14:44:54 -0400 Subject: [PATCH 1/5] fix --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index ed4bb083..10493441 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,15 @@ endif $(libpd): cd dep && git clone "https://github.com/libpd/libpd.git" --recursive cd dep/libpd && git checkout tags/0.15.0 + +ifdef ARCH_WIN + # Some MinGW toolchains define HAVE_ALLOCA_H but do not provide alloca.h. + # Reorder upstream include guards to prefer the _WIN32 branch. + cd dep/libpd && sed -i.bak \ + -e 's/# ifdef HAVE_ALLOCA_H/# if defined _WIN32/' \ + -e 's/# elif defined _WIN32/# elif defined HAVE_ALLOCA_H/' \ + pure-data/src/m_private_utils.h && rm -f pure-data/src/m_private_utils.h.bak +endif ifdef ARCH_MAC # libpd's Makefile is handmade, and it doesn't honor CFLAGS and LDFLAGS environments. From 664caeb3dbdf921dce823e11066f53c701093369 Mon Sep 17 00:00:00 2001 From: Jeremy Wentworth Date: Fri, 20 Mar 2026 14:54:57 -0400 Subject: [PATCH 2/5] fix --- Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile b/Makefile index 10493441..623f3abf 100644 --- a/Makefile +++ b/Makefile @@ -32,15 +32,12 @@ endif $(libpd): cd dep && git clone "https://github.com/libpd/libpd.git" --recursive cd dep/libpd && git checkout tags/0.15.0 - -ifdef ARCH_WIN # Some MinGW toolchains define HAVE_ALLOCA_H but do not provide alloca.h. # Reorder upstream include guards to prefer the _WIN32 branch. cd dep/libpd && sed -i.bak \ -e 's/# ifdef HAVE_ALLOCA_H/# if defined _WIN32/' \ -e 's/# elif defined _WIN32/# elif defined HAVE_ALLOCA_H/' \ pure-data/src/m_private_utils.h && rm -f pure-data/src/m_private_utils.h.bak -endif ifdef ARCH_MAC # libpd's Makefile is handmade, and it doesn't honor CFLAGS and LDFLAGS environments. From ccc7e3af64312bceafa8bc6353c00beb3b6a9d60 Mon Sep 17 00:00:00 2001 From: Jeremy Wentworth Date: Fri, 20 Mar 2026 15:04:00 -0400 Subject: [PATCH 3/5] fix --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 623f3abf..e622c63e 100644 --- a/Makefile +++ b/Makefile @@ -32,12 +32,6 @@ endif $(libpd): cd dep && git clone "https://github.com/libpd/libpd.git" --recursive cd dep/libpd && git checkout tags/0.15.0 - # Some MinGW toolchains define HAVE_ALLOCA_H but do not provide alloca.h. - # Reorder upstream include guards to prefer the _WIN32 branch. - cd dep/libpd && sed -i.bak \ - -e 's/# ifdef HAVE_ALLOCA_H/# if defined _WIN32/' \ - -e 's/# elif defined _WIN32/# elif defined HAVE_ALLOCA_H/' \ - pure-data/src/m_private_utils.h && rm -f pure-data/src/m_private_utils.h.bak ifdef ARCH_MAC # libpd's Makefile is handmade, and it doesn't honor CFLAGS and LDFLAGS environments. @@ -46,7 +40,13 @@ ifdef ARCH_MAC # Perhaps inline assembly is used in libpd? Who knows. cd dep/libpd && $(MAKE) MULTI=true STATIC=true ADDITIONAL_CFLAGS='-DPD_LONGINTTYPE="long long" $(DEP_MAC_SDK_FLAGS) -stdlib=libc++' ADDITIONAL_LDFLAGS='$(DEP_MAC_SDK_FLAGS) -stdlib=libc++' else + ifdef ARCH_WIN + # libpd relies on OS=Windows_NT for platform detection even when cross-compiling. + # Also force heap allocation path to avoid missing alloca.h in some MinGW toolchains. + cd dep/libpd && $(MAKE) OS=Windows_NT MULTI=true STATIC=true ADDITIONAL_CFLAGS='-DPD_LONGINTTYPE="long long" -DDONT_USE_ALLOCA=1' + else cd dep/libpd && $(MAKE) MULTI=true STATIC=true ADDITIONAL_CFLAGS='-DPD_LONGINTTYPE="long long"' + endif endif cd dep/libpd && $(MAKE) install prefix="$(DEP_PATH)" From bfb4a8bd8443a79a3be30ccf2c8cc91d49c2abed Mon Sep 17 00:00:00 2001 From: Jeremy Wentworth Date: Fri, 20 Mar 2026 15:08:50 -0400 Subject: [PATCH 4/5] fix --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index e622c63e..3b091164 100644 --- a/Makefile +++ b/Makefile @@ -40,13 +40,13 @@ ifdef ARCH_MAC # Perhaps inline assembly is used in libpd? Who knows. cd dep/libpd && $(MAKE) MULTI=true STATIC=true ADDITIONAL_CFLAGS='-DPD_LONGINTTYPE="long long" $(DEP_MAC_SDK_FLAGS) -stdlib=libc++' ADDITIONAL_LDFLAGS='$(DEP_MAC_SDK_FLAGS) -stdlib=libc++' else - ifdef ARCH_WIN - # libpd relies on OS=Windows_NT for platform detection even when cross-compiling. - # Also force heap allocation path to avoid missing alloca.h in some MinGW toolchains. - cd dep/libpd && $(MAKE) OS=Windows_NT MULTI=true STATIC=true ADDITIONAL_CFLAGS='-DPD_LONGINTTYPE="long long" -DDONT_USE_ALLOCA=1' - else +ifdef ARCH_WIN + # libpd relies on OS=Windows_NT for platform detection even when cross-compiling. + # Also force heap allocation path to avoid missing alloca.h in some MinGW toolchains. + cd dep/libpd && $(MAKE) OS=Windows_NT MULTI=true STATIC=true ADDITIONAL_CFLAGS='-DPD_LONGINTTYPE="long long" -DDONT_USE_ALLOCA=1' +else cd dep/libpd && $(MAKE) MULTI=true STATIC=true ADDITIONAL_CFLAGS='-DPD_LONGINTTYPE="long long"' - endif +endif endif cd dep/libpd && $(MAKE) install prefix="$(DEP_PATH)" From bd28ca5195300c929b113c59a8fb90acf658ead4 Mon Sep 17 00:00:00 2001 From: Jeremy Wentworth Date: Fri, 20 Mar 2026 15:14:45 -0400 Subject: [PATCH 5/5] fix --- src/PureData.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/PureData.cpp b/src/PureData.cpp index 826f67fa..7bee03e1 100644 --- a/src/PureData.cpp +++ b/src/PureData.cpp @@ -788,13 +788,20 @@ struct PureData : Module { (void) std::system(command.c_str()); #elif defined ARCH_WIN std::string command = editorPath + " \"" + path + "\""; - std::wstring commandW = string::toWstring(command); + int commandWLen = MultiByteToWideChar(CP_UTF8, 0, command.c_str(), -1, NULL, 0); + if (commandWLen <= 0) + return; + std::wstring commandW(commandWLen, L'\0'); + MultiByteToWideChar(CP_UTF8, 0, command.c_str(), -1, &commandW[0], commandWLen); STARTUPINFOW startupInfo; std::memset(&startupInfo, 0, sizeof(startupInfo)); startupInfo.cb = sizeof(startupInfo); PROCESS_INFORMATION processInfo; // Use the non-const [] accessor for commandW. Since C++11, it is null-terminated. - CreateProcessW(NULL, &commandW[0], NULL, NULL, false, 0, NULL, NULL, &startupInfo, &processInfo); + if (CreateProcessW(NULL, &commandW[0], NULL, NULL, false, 0, NULL, NULL, &startupInfo, &processInfo)) { + CloseHandle(processInfo.hThread); + CloseHandle(processInfo.hProcess); + } #endif }