diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index aeaa14db048..8a7e3fabda5 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -275,7 +275,7 @@ P0S q qwe er -@todo_wine@'ty'@or_broken@'' +'ty'@or_broken@'' 't'@or_broken@'' ert@or_broken@qwerty e@or_broken@qwerty diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 89c1327686c..534e5a66f04 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -730,6 +730,7 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, else if (copybytes < 0) copybytes = 0; WCMD_strsubstW(start, endOfVar + 1, startCopy, copybytes); } else { + substrlength = min(substrlength, len - (startCopy- thisVarContents + 1)); WCMD_strsubstW(start, endOfVar + 1, startCopy, substrlength); }