From 645e59c490bcbd57a4a97a076295e171c44a80c1 Mon Sep 17 00:00:00 2001 From: Andrew Nguyen Date: Mon, 18 May 2009 05:07:10 -0500 Subject: [PATCH] kernel32: Correct the last error of CreateProcessW with an empty application name string. --- dlls/kernel32/process.c | 9 ++------- dlls/kernel32/tests/process.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 8f486e0c048..9e6aeaa27d4 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -210,15 +210,10 @@ static HANDLE open_exe_file( const WCHAR *name ) { WCHAR buffer[MAX_PATH]; /* file doesn't exist, check for builtin */ - if (!contains_path( name )) goto error; - if (!get_builtin_path( name, NULL, buffer, sizeof(buffer) )) goto error; - handle = 0; + if (contains_path( name ) && get_builtin_path( name, NULL, buffer, sizeof(buffer) )) + handle = 0; } return handle; - - error: - SetLastError( ERROR_FILE_NOT_FOUND ); - return INVALID_HANDLE_VALUE; } diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index 6aac6151b0b..479a376de7c 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -935,6 +935,26 @@ static void test_CommandLine(void) ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); } + + buffer[0] = '\0'; + + /* Test empty application name parameter. */ + SetLastError(0xdeadbeef); + ret = CreateProcessA(buffer, NULL, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info); + ok(!ret, "CreateProcessA unexpectedly succeeded\n"); + ok(GetLastError() == ERROR_PATH_NOT_FOUND || + broken(GetLastError() == ERROR_ACCESS_DENIED) /* Win98 */, + "Expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError()); + + buffer2[0] = '\0'; + + /* Test empty application name and command line parameters. */ + SetLastError(0xdeadbeef); + ret = CreateProcessA(buffer, buffer2, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info); + ok(!ret, "CreateProcessA unexpectedly succeeded\n"); + ok(GetLastError() == ERROR_PATH_NOT_FOUND || + broken(GetLastError() == ERROR_ACCESS_DENIED) /* Win98 */, + "Expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError()); } static void test_Directory(void)