In 2b4f986e49 (Cygwin: pty: Treat *.bat and *.cmd as a non-cygwin console app., 2022-07-31), we introduced a bug fix that specifically looks for a suffix of the command's file name.
However, that file name might be set to `NULL`, namely when `null_app_name == true`, which is the case when we detected a command-line `cmd /c [...]`. But the commit mentioned above did not account for that possibility, instead assuming that it always has to check the file name for a `.bat` or `.cmd` suffix. As a consequence, `cmd /c [...]` invocations are completely broken in v3.3.6, resulting in a `Bad address` error. Let's guard the code properly so that it does not try to look at the file name suffix of `(WCHAR *)NULL`. This fixes https://github.com/msys2/msys2-runtime/issues/108 Signed-off-by: Johannes Schindelin <johannes.schinde...@gmx.de> --- Published-As: https://github.com/dscho/msys2-runtime/releases/tag/fix-bad-address-in-cmd-invocation-v1 Fetch-It-Via: git fetch https://github.com/dscho/msys2-runtime fix-bad-address-in-cmd-invocation-v1 winsup/cygwin/spawn.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index d9d7716519..d4e7f10e2b 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -209,7 +209,7 @@ is_console_app (WCHAR *filename) char *p = (char *) memmem (buf, n, "PE\0\0", 4); if (p && p + id_offset < buf + n) return p[id_offset] == '\003'; /* 02: GUI, 03: console */ - else + else if (filename) { wchar_t *e = wcsrchr (filename, L'.'); if (e && (wcscasecmp (e, L".bat") == 0 || wcscasecmp (e, L".cmd") == 0)) base-commit: 1ca46b22d6edb3d469b51475e8b096d86deaac67 -- 2.38.1.windows.1