summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2015-06-12 14:22:22 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2015-06-12 14:22:22 +0700
commitb9b7b3d525c9bbcca07ea47e7595fe36e47265ea (patch)
treedc88a26b5a0c871d36347ee872397e767dadc554
parentPerformance optimization (diff)
downloadBouncyCastle.NET-ed25519-b9b7b3d525c9bbcca07ea47e7595fe36e47265ea.tar.xz
Add locking to lazy factory property
-rw-r--r--crypto/src/asn1/x9/X9ECParametersHolder.cs15
1 files changed, 9 insertions, 6 deletions
diff --git a/crypto/src/asn1/x9/X9ECParametersHolder.cs b/crypto/src/asn1/x9/X9ECParametersHolder.cs
index b3455709c..f0a320094 100644
--- a/crypto/src/asn1/x9/X9ECParametersHolder.cs
+++ b/crypto/src/asn1/x9/X9ECParametersHolder.cs
@@ -8,13 +8,16 @@ namespace Org.BouncyCastle.Asn1.X9
 		{
 			get
 			{
-				if (parameters == null)
-				{
-					parameters = CreateParameters();
-				}
+                lock (this)
+                {
+				    if (parameters == null)
+				    {
+					    parameters = CreateParameters();
+				    }
 
-				return parameters;
-			}
+                    return parameters;
+                }
+            }
 		}
 
 		protected abstract X9ECParameters CreateParameters();