kernelbase: Don't allow converting thread to fiber more than once.
Signed-off-by: Paul Gofman <pgofman@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
15bc605224
commit
90d3b9a313
|
@ -128,10 +128,17 @@ static VOID WINAPI FiberMainProc(LPVOID lpFiberParameter)
|
||||||
|
|
||||||
static void test_ConvertThreadToFiber(void)
|
static void test_ConvertThreadToFiber(void)
|
||||||
{
|
{
|
||||||
|
void *ret;
|
||||||
|
|
||||||
if (pConvertThreadToFiber)
|
if (pConvertThreadToFiber)
|
||||||
{
|
{
|
||||||
fibers[0] = pConvertThreadToFiber(&testparam);
|
fibers[0] = pConvertThreadToFiber(&testparam);
|
||||||
ok(fibers[0] != NULL, "ConvertThreadToFiber failed with error %u\n", GetLastError());
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -141,10 +148,17 @@ static void test_ConvertThreadToFiber(void)
|
||||||
|
|
||||||
static void test_ConvertThreadToFiberEx(void)
|
static void test_ConvertThreadToFiberEx(void)
|
||||||
{
|
{
|
||||||
|
void *ret;
|
||||||
|
|
||||||
if (pConvertThreadToFiberEx)
|
if (pConvertThreadToFiberEx)
|
||||||
{
|
{
|
||||||
fibers[0] = pConvertThreadToFiberEx(&testparam, 0);
|
fibers[0] = pConvertThreadToFiberEx(&testparam, 0);
|
||||||
ok(fibers[0] != NULL, "ConvertThreadToFiberEx failed with error %u\n", GetLastError());
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -990,6 +990,12 @@ LPVOID WINAPI DECLSPEC_HOTPATCH ConvertThreadToFiberEx( LPVOID param, DWORD flag
|
||||||
{
|
{
|
||||||
struct fiber_data *fiber;
|
struct fiber_data *fiber;
|
||||||
|
|
||||||
|
if (NtCurrentTeb()->Tib.u.FiberData)
|
||||||
|
{
|
||||||
|
SetLastError( ERROR_ALREADY_FIBER );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(fiber = HeapAlloc( GetProcessHeap(), 0, sizeof(*fiber) )))
|
if (!(fiber = HeapAlloc( GetProcessHeap(), 0, sizeof(*fiber) )))
|
||||||
{
|
{
|
||||||
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
|
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
|
||||||
|
|
Loading…
Reference in New Issue