From 4f6d085073cab7ff60f1d31d881c778c8d5cc692 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 18 Feb 2010 14:06:10 +0100 Subject: [PATCH] advapi32/tests: Avoid crashing if ReadEventLogA fails. --- dlls/advapi32/tests/eventlog.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/dlls/advapi32/tests/eventlog.c b/dlls/advapi32/tests/eventlog.c index c0f516acd6f..3907873835f 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()); -- 2.11.4.GIT