From 0c33682330dae057e5984a5f2d19ac119fb14c5f Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 8 Apr 2011 13:31:33 +0400 Subject: [PATCH] ole32: Handle null argument in OleIsRunning(). --- dlls/ole32/ole2.c | 8 +++++--- dlls/ole32/tests/ole2.c | 14 +++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/dlls/ole32/ole2.c b/dlls/ole32/ole2.c index d5fd2c2b670..3254619eab2 100644 --- a/dlls/ole32/ole2.c +++ b/dlls/ole32/ole2.c @@ -2628,15 +2628,17 @@ HRESULT WINAPI OleDoAutoConvert(LPSTORAGE pStg, LPCLSID pClsidNew) /****************************************************************************** * OleIsRunning [OLE32.@] */ -BOOL WINAPI OleIsRunning(LPOLEOBJECT pObject) +BOOL WINAPI OleIsRunning(LPOLEOBJECT object) { IRunnableObject *pRunnable; HRESULT hr; BOOL running; - TRACE("(%p)\n", pObject); + TRACE("(%p)\n", object); - hr = IOleObject_QueryInterface(pObject, &IID_IRunnableObject, (void **)&pRunnable); + if (!object) return FALSE; + + hr = IOleObject_QueryInterface(object, &IID_IRunnableObject, (void **)&pRunnable); if (FAILED(hr)) return TRUE; running = IRunnableObject_IsRunning(pRunnable); diff --git a/dlls/ole32/tests/ole2.c b/dlls/ole32/tests/ole2.c index 89611864bdc..f38af3b94a8 100644 --- a/dlls/ole32/tests/ole2.c +++ b/dlls/ole32/tests/ole2.c @@ -1784,20 +1784,28 @@ static void test_runnable(void) { NULL, 0 } }; + BOOL ret; IOleObject *object = &OleObject; + /* null argument */ + ret = OleIsRunning(NULL); + ok(ret == FALSE, "got %d\n", ret); + expected_method_list = methods_query_runnable; - ok(OleIsRunning(object), "Object should be running\n"); + ret = OleIsRunning(object); + ok(ret == TRUE, "Object should be running\n"); CHECK_NO_EXTRA_METHODS(); g_isRunning = FALSE; expected_method_list = methods_query_runnable; - ok(OleIsRunning(object) == FALSE, "Object should not be running\n"); + ret = OleIsRunning(object); + ok(ret == FALSE, "Object should not be running\n"); CHECK_NO_EXTRA_METHODS(); g_showRunnable = FALSE; /* QueryInterface(IID_IRunnableObject, ...) will fail */ expected_method_list = methods_no_runnable; - ok(OleIsRunning(object), "Object without IRunnableObject should be running\n"); + ret = OleIsRunning(object); + ok(ret == TRUE, "Object without IRunnableObject should be running\n"); CHECK_NO_EXTRA_METHODS(); g_isRunning = TRUE;