Author: ion
Date: Sat Jul 23 11:46:57 2011
New Revision: 52803

URL: http://svn.reactos.org/svn/reactos?rev=52803&view=rev
Log:
[KERNEL32]
Bug #43: ConvertFiberToThread should return ERROR_ALREADY_THREAD, not 
ERROR_INVALID_PARAMETER in case of failure.
Bug #44: ConvertFiberToThread should set FiberData to NULL in the TEB, after 
doing the conversion.
Thanks, Winetests, for saying "0 failures", when this API was broken.

Modified:
    trunk/reactos/dll/win32/kernel32/client/fiber.c

Modified: trunk/reactos/dll/win32/kernel32/client/fiber.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/fiber.c?rev=52803&r1=52802&r2=52803&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/fiber.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/fiber.c [iso-8859-1] Sat Jul 23 
11:46:57 2011
@@ -59,24 +59,27 @@
 WINAPI
 ConvertFiberToThread(VOID)
 {
-    PTEB pTeb = NtCurrentTeb();
+    PTEB Teb;
+    PFIBER FiberData;
     DPRINT1("Converting Fiber to Thread\n");
 
-    /* the current thread isn't running a fiber: failure */
-    if (!pTeb->HasFiberData)
-    {
-        SetLastError(ERROR_INVALID_PARAMETER);
+    /* Check if the thread is already not a fiber */
+    Teb = NtCurrentTeb();
+    if (!Teb->HasFiberData)
+    {
+        /* Fail */
+        SetLastError(ERROR_ALREADY_THREAD);
         return FALSE;
     }
 
     /* this thread won't run a fiber anymore */
-    pTeb->HasFiberData = FALSE;
-
-    /* free the fiber */
-    if(pTeb->NtTib.FiberData != NULL)
-    {
-        RtlFreeHeap(GetProcessHeap(), 0, pTeb->NtTib.FiberData);
-    }
+    Teb->HasFiberData = FALSE;
+    FiberData = Teb->NtTib.FiberData;
+    Teb->NtTib.FiberData = NULL;
+
+    /* Free the fiber */
+    ASSERT(FiberData != NULL);
+    RtlFreeHeap(GetProcessHeap(), 0, FiberData);
 
     /* success */
     return TRUE;


Reply via email to