Commit 7c2c6a57 authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

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

parent 645e59c4
......@@ -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 );
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment