diff --git a/src/dmd/link.d b/src/dmd/link.d index 86f6fc7ba9e6..4a0f9c3d22ef 100644 --- a/src/dmd/link.d +++ b/src/dmd/link.d @@ -1052,9 +1052,10 @@ version (Windows) // try lld-link.exe alongside dmd.exe char[MAX_PATH + 1] dmdpath = void; - if (GetModuleFileNameA(null, dmdpath.ptr, dmdpath.length) <= MAX_PATH) + const len = GetModuleFileNameA(null, dmdpath.ptr, dmdpath.length); + if (len <= MAX_PATH) { - auto lldpath = FileName.replaceName(dmdpath, "lld-link.exe"); + auto lldpath = FileName.replaceName(dmdpath[0 .. len], "lld-link.exe"); if (FileName.exists(lldpath)) return lldpath.ptr; }