summary refs log tree commit diff
diff options
context:
space:
mode:
authorJozef Gajdos <jozef.gajdos@disig.sk>2023-02-17 10:11:11 +0100
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-02-17 17:33:28 +0700
commitb3480a29cca5120ca386fae3586c4165cc50ae4f (patch)
treebbfd5fd5b088847f30e2d2acc8b8952eceb63c9c
parentRemoving unnecessary locks in X509Certificate and X509Crl (diff)
downloadBouncyCastle.NET-ed25519-b3480a29cca5120ca386fae3586c4165cc50ae4f.tar.xz
Update return values.
-rw-r--r--crypto/src/x509/X509Certificate.cs6
-rw-r--r--crypto/src/x509/X509Crl.cs3
2 files changed, 3 insertions, 6 deletions
diff --git a/crypto/src/x509/X509Certificate.cs b/crypto/src/x509/X509Certificate.cs
index aec793731..f58477439 100644
--- a/crypto/src/x509/X509Certificate.cs
+++ b/crypto/src/x509/X509Certificate.cs
@@ -477,8 +477,7 @@ namespace Org.BouncyCastle.X509
 
             AsymmetricKeyParameter temp = PublicKeyFactory.CreateKey(c.SubjectPublicKeyInfo);
 
-            Interlocked.CompareExchange(ref publicKeyValue, temp, null);
-            return publicKeyValue;
+            return Interlocked.CompareExchange(ref publicKeyValue, temp, null) ?? temp;
         }
 
         /// <summary>
@@ -699,8 +698,7 @@ namespace Org.BouncyCastle.X509
 
             CachedEncoding temp = new CachedEncoding(encoding, exception);
 
-            Interlocked.CompareExchange(ref cachedEncoding, temp, null);
-            return cachedEncoding;
+           return Interlocked.CompareExchange(ref cachedEncoding, temp, null) ?? temp;
         }
 
         private static bool IsAlgIDEqual(AlgorithmIdentifier id1, AlgorithmIdentifier id2)
diff --git a/crypto/src/x509/X509Crl.cs b/crypto/src/x509/X509Crl.cs
index e47addd7a..b4af1b374 100644
--- a/crypto/src/x509/X509Crl.cs
+++ b/crypto/src/x509/X509Crl.cs
@@ -466,8 +466,7 @@ namespace Org.BouncyCastle.X509
 
             CachedEncoding temp = new CachedEncoding(encoding, exception);
 
-			Interlocked.CompareExchange(ref cachedEncoding, temp, null);
-            return cachedEncoding;
+			return Interlocked.CompareExchange(ref cachedEncoding, temp, null) ?? temp;
         }
     }
 }