Index: nss/lib/nss/nssinit.c |
diff --git a/nss/lib/nss/nssinit.c b/nss/lib/nss/nssinit.c |
index 83e50d2c45bb68eae30e6ee4a9f7877412f26515..208e71dd3cd390643526d975350bd3b0c1f8fa46 100644 |
--- a/nss/lib/nss/nssinit.c |
+++ b/nss/lib/nss/nssinit.c |
@@ -1099,14 +1099,6 @@ nss_Shutdown(void) |
shutdownRV = SECFailure; |
} |
pk11sdr_Shutdown(); |
- /* |
- * A thread's error stack is automatically destroyed when the thread |
- * terminates, except for the primordial thread, whose error stack is |
- * destroyed by PR_Cleanup. Since NSS is usually shut down by the |
- * primordial thread and many NSS-based apps don't call PR_Cleanup, |
- * we destroy the calling thread's error stack here. |
- */ |
- nss_DestroyErrorStack(); |
nssArena_Shutdown(); |
if (status == PR_FAILURE) { |
if (NSS_GetError() == NSS_ERROR_BUSY) { |
@@ -1114,6 +1106,16 @@ nss_Shutdown(void) |
} |
shutdownRV = SECFailure; |
} |
+ /* |
+ * A thread's error stack is automatically destroyed when the thread |
+ * terminates, except for the primordial thread, whose error stack is |
+ * destroyed by PR_Cleanup. Since NSS is usually shut down by the |
+ * primordial thread and many NSS-based apps don't call PR_Cleanup, |
+ * we destroy the calling thread's error stack here. This must be |
+ * done after any NSS_GetError call, otherwise NSS_GetError will |
+ * create the error stack again. |
+ */ |
+ nss_DestroyErrorStack(); |
nssIsInitted = PR_FALSE; |
temp = nssInitContextList; |
nssInitContextList = NULL; |