From 984b16085d973ad8aecd63ac486eea42708daeba Mon Sep 17 00:00:00 2001 From: "timeless%mozdev.org" Date: Thu, 26 Aug 2004 12:31:56 +0000 Subject: [PATCH] Bug 256615 crash when calling nsIThread.state before calling nsIThread.init [@ PR_GetThreadState] patch by cst@andrew.cmu.edu r=dougt git-svn-id: svn://10.0.0.236/trunk@161312 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/threads/nsThread.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mozilla/xpcom/threads/nsThread.cpp b/mozilla/xpcom/threads/nsThread.cpp index a0a902f49e4..a8529a718da 100644 --- a/mozilla/xpcom/threads/nsThread.cpp +++ b/mozilla/xpcom/threads/nsThread.cpp @@ -175,6 +175,8 @@ nsThread::Join() PR_LOG(nsIThreadLog, PR_LOG_DEBUG, ("nsIThread %p start join\n", this)); + if (!mThread) + return NS_ERROR_NOT_INITIALIZED; PRStatus status = PR_JoinThread(mThread); // XXX can't use NS_RELEASE here because the macro wants to set // this to null (bad c++) @@ -193,6 +195,8 @@ nsThread::GetPriority(PRThreadPriority *result) { if (mDead) return NS_ERROR_FAILURE; + if (!mThread) + return NS_ERROR_NOT_INITIALIZED; *result = PR_GetThreadPriority(mThread); return NS_OK; } @@ -202,6 +206,8 @@ nsThread::SetPriority(PRThreadPriority value) { if (mDead) return NS_ERROR_FAILURE; + if (!mThread) + return NS_ERROR_NOT_INITIALIZED; PR_SetThreadPriority(mThread, value); return NS_OK; } @@ -211,6 +217,8 @@ nsThread::Interrupt() { if (mDead) return NS_ERROR_FAILURE; + if (!mThread) + return NS_ERROR_NOT_INITIALIZED; PRStatus status = PR_Interrupt(mThread); return status == PR_SUCCESS ? NS_OK : NS_ERROR_FAILURE; } @@ -220,6 +228,8 @@ nsThread::GetScope(PRThreadScope *result) { if (mDead) return NS_ERROR_FAILURE; + if (!mThread) + return NS_ERROR_NOT_INITIALIZED; *result = PR_GetThreadScope(mThread); return NS_OK; } @@ -229,6 +239,8 @@ nsThread::GetState(PRThreadState *result) { if (mDead) return NS_ERROR_FAILURE; + if (!mThread) + return NS_ERROR_NOT_INITIALIZED; *result = PR_GetThreadState(mThread); return NS_OK; }