[PATCH] V2 [cmd] - remove trailing spaces in WCMD_addComman
Vijay Kiran Kamuju
infyquest at gmail.com
Fri Dec 22 12:57:54 CST 2017
https://bugs.winehq.org/show_bug.cgi?id=40694
Signed-off-by: Vijay Kiran Kamuju <infyquest at gmail.com>
---
programs/cmd/tests/test_cmdline.cmd | 4 ++++
programs/cmd/wcmdmain.c | 7 +++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/programs/cmd/tests/test_cmdline.cmd b/programs/cmd/tests/test_cmdline.cmd
index 32a1ef2e48f..caac7b07144 100644
--- a/programs/cmd/tests/test_cmdline.cmd
+++ b/programs/cmd/tests/test_cmdline.cmd
@@ -86,6 +86,10 @@ cmd.exe /c ECHO %%VAR%%
rem - Exit works
cmd.exe /c exit
+rem - Change drive
+cmd.exe /c C:
+cmd.exe /c "C: &"
+cmd.exe /c "C: > NUL"
cd ..
rd foobar /s /q
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 827ddd21219..f89bd04e650 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -1686,9 +1686,12 @@ static void WCMD_addCommand(WCHAR *command, int *commandLen,
/* Copy in the command */
if (command) {
+ WCHAR *tend = command + *commandLen + 1;
thisEntry->command = heap_alloc((*commandLen+1) * sizeof(WCHAR));
- memcpy(thisEntry->command, command, *commandLen * sizeof(WCHAR));
- thisEntry->command[*commandLen] = 0x00;
+ while (tend > command && isspaceW(*tend)) tend--;
+ memcpy(thisEntry->command, command, (tend - command + 2) * sizeof(WCHAR));
+ thisEntry->command[tend - command + 1] = 0x00;
+ heap_free(tend);
/* Copy in the redirects */
thisEntry->redirects = heap_alloc((*redirLen+1) * sizeof(WCHAR));
--
2.15.1
More information about the wine-patches
mailing list