summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2020-08-21 11:51:58 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2020-08-21 11:51:58 +0900
commit65a2cd139e21250e6581a4f610015937e7b91451 (patch)
tree31b3a7c58ccfa8de95e9ff85ea05b2e5b2d1e53c
parent8d7b1d0a52bde173646e5b42b31d23593eabecf2 (diff)
downloadlibgcrypt-65a2cd139e21250e6581a4f610015937e7b91451.tar.gz
ecc: Fix an error path.
* cipher/ecc-ecdh.c (_gcry_ecc_mul_point): Avoid null dereference on error. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
-rw-r--r--cipher/ecc-ecdh.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/cipher/ecc-ecdh.c b/cipher/ecc-ecdh.c
index 615b108d..39458788 100644
--- a/cipher/ecc-ecdh.c
+++ b/cipher/ecc-ecdh.c
@@ -112,8 +112,11 @@ _gcry_ecc_mul_point (int algo, unsigned char *result,
buf = _gcry_mpi_get_buffer (x, nbytes, &len, NULL);
if (!buf)
err = gpg_error_from_syserror ();
- memcpy (result, buf, nbytes);
- xfree (buf);
+ else
+ {
+ memcpy (result, buf, nbytes);
+ xfree (buf);
+ }
leave:
_gcry_mpi_release (x);