Andrew Nguyen : kernel32: Correct the last error of CreateProcessW with an empty command line string .
Alexandre Julliard
julliard at winehq.org
Mon May 18 08:13:19 CDT 2009
Module: wine
Branch: master
Commit: 7c2c6a575c74190864f2659f188d609eaab73d05
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7c2c6a575c74190864f2659f188d609eaab73d05
Author: Andrew Nguyen <arethusa26 at gmail.com>
Date: Mon May 18 05:07:18 2009 -0500
kernel32: Correct the last error of CreateProcessW with an empty command line string.
---
dlls/kernel32/process.c | 1 +
dlls/kernel32/tests/process.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index 9e6aeaa..f00d972 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -1824,6 +1824,7 @@ static LPWSTR get_file_name( LPCWSTR appname, LPWSTR cmdline, LPWSTR buffer,
sprintfW( ret, quotesW, name );
strcatW( ret, p );
}
+ else if (!ret) SetLastError( ERROR_FILE_NOT_FOUND );
done:
HeapFree( GetProcessHeap(), 0, name );
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c
index 479a376..83b61ad 100644
--- a/dlls/kernel32/tests/process.c
+++ b/dlls/kernel32/tests/process.c
@@ -955,6 +955,40 @@ static void test_CommandLine(void)
ok(GetLastError() == ERROR_PATH_NOT_FOUND ||
broken(GetLastError() == ERROR_ACCESS_DENIED) /* Win98 */,
"Expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
+
+ /* Test empty command line parameter. */
+ SetLastError(0xdeadbeef);
+ ret = CreateProcessA(NULL, buffer2, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
+ ok(!ret, "CreateProcessA unexpectedly succeeded\n");
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND ||
+ GetLastError() == ERROR_PATH_NOT_FOUND /* NT4 */ ||
+ GetLastError() == ERROR_BAD_PATHNAME /* Win98 */,
+ "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+
+ strcpy(buffer, "doesnotexist.exe");
+ strcpy(buffer2, "does not exist.exe");
+
+ /* Test nonexistent application name. */
+ SetLastError(0xdeadbeef);
+ ret = CreateProcessA(buffer, NULL, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
+ ok(!ret, "CreateProcessA unexpectedly succeeded\n");
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = CreateProcessA(buffer2, NULL, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
+ ok(!ret, "CreateProcessA unexpectedly succeeded\n");
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+
+ /* Test nonexistent command line parameter. */
+ SetLastError(0xdeadbeef);
+ ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
+ ok(!ret, "CreateProcessA unexpectedly succeeded\n");
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = CreateProcessA(NULL, buffer2, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
+ ok(!ret, "CreateProcessA unexpectedly succeeded\n");
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
}
static void test_Directory(void)
More information about the wine-cvs
mailing list