Re: [PATCH] user32: Fix error handling in MapWindowPoints, ClientToScreen and ScreenToClient and add tests for them.
Christian Costa <titan.costa(a)gmail.com> wrote:
-BOOL WINAPI ClientToScreen( HWND hwnd, LPPOINT lppnt ) +BOOL WINAPI ClientToScreen( HWND wnd, LPPOINT point ) { - MapWindowPoints( hwnd, 0, lppnt, 1 ); + DWORD error = GetLastError(); + + if (!wnd) + { + SetLastError( ERROR_INVALID_WINDOW_HANDLE ); + return FALSE; + } + + SetLastError( 0xdeadbeef ); + MapWindowPoints( wnd, 0, point, 1 ); + + if (GetLastError() != 0xdeadbeef) + return FALSE; + + SetLastError(error); return TRUE; }
All this logic with saving/restoring last error code is wrong (here and in another places), there is no need for that. -- Dmitry.
Le 20/10/2012 03:59, Dmitry Timoshkov a écrit :
Christian Costa <titan.costa(a)gmail.com> wrote:
-BOOL WINAPI ClientToScreen( HWND hwnd, LPPOINT lppnt ) +BOOL WINAPI ClientToScreen( HWND wnd, LPPOINT point ) { - MapWindowPoints( hwnd, 0, lppnt, 1 ); + DWORD error = GetLastError(); + + if (!wnd) + { + SetLastError( ERROR_INVALID_WINDOW_HANDLE ); + return FALSE; + } + + SetLastError( 0xdeadbeef ); + MapWindowPoints( wnd, 0, point, 1 ); + + if (GetLastError() != 0xdeadbeef) + return FALSE; + + SetLastError(error); return TRUE; } All this logic with saving/restoring last error code is wrong (here and in another places), there is no need for that.
I'm not it is wrong but I can do certainly do it differently.
participants (2)
-
Christian Costa -
Dmitry Timoshkov