[PATCH] programs/cmd: don't crash on 'if exist' without parameter

Eric Pouech eric.pouech at gmail.com
Mon Dec 20 03:29:01 CST 2021


fixes BZ #51598
https://bugs.winehq.org/show_bug.cgi?id=51598

Signed-off-by: Eric Pouech <eric.pouech at gmail.com>

---
 programs/cmd/builtins.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index d0a954d90fa..d14e69e072a 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -2811,8 +2811,9 @@ int evaluate_if_condition(WCHAR *p, WCHAR **command, int *test, int *negate)
     WCHAR *param = WCMD_parameter(p, 1+(*negate), NULL, FALSE, FALSE);
     int    len = lstrlenW(param);
 
+    if (!len) goto syntax_err;
     /* FindFirstFile does not like a directory path ending in '\', append a '.' */
-    if (len && param[len-1] == '\\') lstrcatW(param, L".");
+    if (param[len-1] == '\\') lstrcatW(param, L".");
 
     hff = FindFirstFileW(param, &fd);
     *test = (hff != INVALID_HANDLE_VALUE );




More information about the wine-devel mailing list