summary refs log tree commit diff
path: root/crypto/src/openpgp/PgpPublicKey.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/openpgp/PgpPublicKey.cs')
-rw-r--r--crypto/src/openpgp/PgpPublicKey.cs6
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/src/openpgp/PgpPublicKey.cs b/crypto/src/openpgp/PgpPublicKey.cs
index 6d5f35018..cdb8efd36 100644
--- a/crypto/src/openpgp/PgpPublicKey.cs
+++ b/crypto/src/openpgp/PgpPublicKey.cs
@@ -510,8 +510,10 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
             BigInteger encodedPoint = ecK.EncodedPoint;
 
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
-            int encodingLength = BigIntegers.GetUnsignedByteLength(encodedPoint);
-            Span<byte> encoding = stackalloc byte[encodingLength];
+            int encodedLength = BigIntegers.GetUnsignedByteLength(encodedPoint);
+            Span<byte> encoding = encodedLength <= 512
+                ? stackalloc byte[encodedLength]
+                : new byte[encodedLength];
             BigIntegers.AsUnsignedByteArray(encodedPoint, encoding);
             ECPoint q = x9.Curve.DecodePoint(encoding);
 #else