summaryrefslogtreecommitdiff
path: root/mpi/mpiutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'mpi/mpiutil.c')
-rw-r--r--mpi/mpiutil.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c
index fbbd3b47..71b3f1c3 100644
--- a/mpi/mpiutil.c
+++ b/mpi/mpiutil.c
@@ -343,7 +343,8 @@ _gcry_mpi_copy (gcry_mpi_t a)
if( a && (a->flags & 4) ) {
void *p = _gcry_is_secure(a->d)? xmalloc_secure ((a->sign+7)/8)
: xmalloc ((a->sign+7)/8);
- memcpy( p, a->d, (a->sign+7)/8 );
+ if (a->d)
+ memcpy( p, a->d, (a->sign+7)/8 );
b = mpi_set_opaque( NULL, p, a->sign );
b->flags &= ~(16|32); /* Reset the immutable and constant flags. */
}