Commit 90d3b9a3 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

kernelbase: Don't allow converting thread to fiber more than once.

parent 15bc6052
......@@ -128,10 +128,17 @@ static VOID WINAPI FiberMainProc(LPVOID lpFiberParameter)
static void test_ConvertThreadToFiber(void)
{
void *ret;
if (pConvertThreadToFiber)
{
fibers[0] = pConvertThreadToFiber(&testparam);
ok(fibers[0] != NULL, "ConvertThreadToFiber failed with error %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = pConvertThreadToFiber(&testparam);
ok(!ret, "Got non NULL ret.\n");
ok(GetLastError() == ERROR_ALREADY_FIBER, "Got unexpected error %u.\n", GetLastError());
}
else
{
......@@ -141,10 +148,17 @@ static void test_ConvertThreadToFiber(void)
static void test_ConvertThreadToFiberEx(void)
{
void *ret;
if (pConvertThreadToFiberEx)
{
fibers[0] = pConvertThreadToFiberEx(&testparam, 0);
ok(fibers[0] != NULL, "ConvertThreadToFiberEx failed with error %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = pConvertThreadToFiberEx(&testparam, 0);
ok(!ret, "Got non NULL ret.\n");
ok(GetLastError() == ERROR_ALREADY_FIBER, "Got unexpected error %u.\n", GetLastError());
}
else
{
......
......@@ -990,6 +990,12 @@ LPVOID WINAPI DECLSPEC_HOTPATCH ConvertThreadToFiberEx( LPVOID param, DWORD flag
{
struct fiber_data *fiber;
if (NtCurrentTeb()->Tib.u.FiberData)
{
SetLastError( ERROR_ALREADY_FIBER );
return NULL;
}
if (!(fiber = HeapAlloc( GetProcessHeap(), 0, sizeof(*fiber) )))
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
......
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