kernel32: Correct the last error of CreateProcessW with an empty command line string.

This commit is contained in:
Andrew Nguyen 2009-05-18 05:07:18 -05:00 committed by Alexandre Julliard
parent 645e59c490
commit 7c2c6a575c
2 changed files with 35 additions and 0 deletions

View file

@ -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 );

View file

@ -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)