From cfe617a4a720a887a7933fceed1e96d969e98f91 Mon Sep 17 00:00:00 2001 From: "timeless%mozdev.org" Date: Fri, 4 Apr 2003 15:56:37 +0000 Subject: [PATCH] Bug 200424 nsEventQueueServiceImpl::GetThreadEventQueue might return NS_OK w/ null out [@ nsMemoryImpl::FlushMemory] r=darin --- xpcom/threads/nsEventQueueService.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/xpcom/threads/nsEventQueueService.cpp b/xpcom/threads/nsEventQueueService.cpp index e20ccc4506a..2f07cfee282 100644 --- a/xpcom/threads/nsEventQueueService.cpp +++ b/xpcom/threads/nsEventQueueService.cpp @@ -348,8 +348,6 @@ nsEventQueueServiceImpl::PopThreadEventQueue(nsIEventQueue *aQueue) NS_IMETHODIMP nsEventQueueServiceImpl::GetThreadEventQueue(PRThread* aThread, nsIEventQueue** aResult) { - nsresult rv = NS_OK; - /* Parameter validation... */ if (NULL == aResult) return NS_ERROR_NULL_POINTER; @@ -364,7 +362,7 @@ nsEventQueueServiceImpl::GetThreadEventQueue(PRThread* aThread, nsIEventQueue** nsCOMPtr mainIThread; // Get the primordial thread - rv = nsIThread::GetMainThread(getter_AddRefs(mainIThread)); + nsresult rv = nsIThread::GetMainThread(getter_AddRefs(mainIThread)); if (NS_FAILED(rv)) return rv; rv = mainIThread->GetPRThread(&keyThread); @@ -380,18 +378,17 @@ nsEventQueueServiceImpl::GetThreadEventQueue(PRThread* aThread, nsIEventQueue** PR_ExitMonitor(mEventQMonitor); + nsCOMPtr youngestQueue; if (queue) { - nsCOMPtr youngestQueue; GetYoungestEventQueue(queue, getter_AddRefs(youngestQueue)); // get the youngest active queue - *aResult = youngestQueue; - NS_IF_ADDREF(*aResult); - } else { - // XXX: Need error code for requesting an event queue when none exists... - *aResult = NULL; - rv = NS_ERROR_FAILURE; } - - return rv; + *aResult = youngestQueue; + // XXX: Need error code for requesting an event queue when none exists... + if (!youngestQueue) { + return NS_ERROR_NOT_AVAILABLE; + } + NS_ADDREF(*aResult); + return NS_OK; }