Alexandre Julliard : advapi32/tests: Avoid crashing if ReadEventLogA fails.

Alexandre Julliard julliard at winehq.org
Thu Feb 18 12:49:24 CST 2010


Module: wine
Branch: master
Commit: 4f6d085073cab7ff60f1d31d881c778c8d5cc692
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4f6d085073cab7ff60f1d31d881c778c8d5cc692

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Feb 18 14:06:10 2010 +0100

advapi32/tests: Avoid crashing if ReadEventLogA fails.

---

 dlls/advapi32/tests/eventlog.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/dlls/advapi32/tests/eventlog.c b/dlls/advapi32/tests/eventlog.c
index c0f516a..3907873 100644
--- a/dlls/advapi32/tests/eventlog.c
+++ b/dlls/advapi32/tests/eventlog.c
@@ -776,21 +776,21 @@ static void test_readwrite(void)
 
         /* Needed to catch earlier Vista (with no ServicePack for example) */
         buf = HeapAlloc(GetProcessHeap(), 0, sizeof(EVENTLOGRECORD));
-        ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ,
-                      0, buf, sizeof(EVENTLOGRECORD), &read, &needed);
-
-        buf = HeapReAlloc(GetProcessHeap(), 0, buf, needed);
-        ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ,
-                      0, buf, needed, &read, &needed);
-
-        record = (EVENTLOGRECORD *)buf;
+        if (ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ,
+                          0, buf, sizeof(EVENTLOGRECORD), &read, &needed))
+        {
+            buf = HeapReAlloc(GetProcessHeap(), 0, buf, needed);
+            ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ,
+                          0, buf, needed, &read, &needed);
 
-        /* Vista and W2K8 return EVENTLOG_SUCCESS, Windows versions before return
-         * the written eventtype (0x20 in this case).
-         */
-        if (record->EventType == EVENTLOG_SUCCESS)
-            on_vista = TRUE;
+            record = (EVENTLOGRECORD *)buf;
 
+            /* Vista and W2K8 return EVENTLOG_SUCCESS, Windows versions before return
+             * the written eventtype (0x20 in this case).
+             */
+            if (record->EventType == EVENTLOG_SUCCESS)
+                on_vista = TRUE;
+        }
         HeapFree(GetProcessHeap(), 0, buf);
     }
     ok(ret, "Expected success : %d\n", GetLastError());




More information about the wine-cvs mailing list