Alexandre Julliard : kernel32/tests: Don' t crash the test if GetThreadContext fails.
Alexandre Julliard
julliard at winehq.org
Tue Nov 20 10:55:03 CST 2007
Module: wine
Branch: master
Commit: 58b85bba3ea2359ba60ad7efdf59f94d37835d89
URL: http://source.winehq.org/git/wine.git/?a=commit;h=58b85bba3ea2359ba60ad7efdf59f94d37835d89
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Nov 20 17:53:43 2007 +0100
kernel32/tests: Don't crash the test if GetThreadContext fails.
---
dlls/kernel32/tests/thread.c | 25 +++++++++++++++----------
1 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/dlls/kernel32/tests/thread.c b/dlls/kernel32/tests/thread.c
index 38692d4..6b90ad1 100644
--- a/dlls/kernel32/tests/thread.c
+++ b/dlls/kernel32/tests/thread.c
@@ -795,6 +795,7 @@ static void test_SetThreadContext(void)
HANDLE thread;
DWORD threadid;
DWORD prevcount;
+ BOOL ret;
SetLastError(0xdeadbeef);
event = CreateEvent( NULL, TRUE, FALSE, NULL );
@@ -811,16 +812,20 @@ static void test_SetThreadContext(void)
ctx.ContextFlags = CONTEXT_FULL;
SetLastError(0xdeadbeef);
- ok( GetThreadContext( thread, &ctx ), "GetThreadContext failed : (%d)\n", GetLastError() );
-
- /* simulate a call to set_test_val(10) */
- stack = (int *)ctx.Esp;
- stack[-1] = 10;
- stack[-2] = ctx.Eip;
- ctx.Esp -= 2 * sizeof(int *);
- ctx.Eip = (DWORD)set_test_val;
- SetLastError(0xdeadbeef);
- ok( SetThreadContext( thread, &ctx ), "SetThreadContext failed : (%d)\n", GetLastError() );
+ ret = GetThreadContext( thread, &ctx );
+ ok( ret, "GetThreadContext failed : (%u)\n", GetLastError() );
+
+ if (ret)
+ {
+ /* simulate a call to set_test_val(10) */
+ stack = (int *)ctx.Esp;
+ stack[-1] = 10;
+ stack[-2] = ctx.Eip;
+ ctx.Esp -= 2 * sizeof(int *);
+ ctx.Eip = (DWORD)set_test_val;
+ SetLastError(0xdeadbeef);
+ ok( SetThreadContext( thread, &ctx ), "SetThreadContext failed : (%d)\n", GetLastError() );
+ }
SetLastError(0xdeadbeef);
prevcount = ResumeThread( thread );
More information about the wine-cvs
mailing list