summaryrefslogtreecommitdiff
path: root/g10/keyid.c
diff options
context:
space:
mode:
Diffstat (limited to 'g10/keyid.c')
-rw-r--r--g10/keyid.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/g10/keyid.c b/g10/keyid.c
index 9f7b70f..a0571b0 100644
--- a/g10/keyid.c
+++ b/g10/keyid.c
@@ -179,7 +179,10 @@ hash_public_key (gcry_md_hd_t md, PKT_public_key *pk)
p = gcry_mpi_get_opaque (pk->pkey[i], &nbits);
pp[i] = xmalloc ((nbits+7)/8);
- memcpy (pp[i], p, (nbits+7)/8);
+ if (p)
+ memcpy (pp[i], p, (nbits+7)/8);
+ else
+ pp[i] = NULL;
nn[i] = (nbits+7)/8;
n += nn[i];
}
@@ -214,14 +217,18 @@ hash_public_key (gcry_md_hd_t md, PKT_public_key *pk)
if(npkey==0 && pk->pkey[0]
&& gcry_mpi_get_flag (pk->pkey[0], GCRYMPI_FLAG_OPAQUE))
{
- gcry_md_write (md, pp[0], nn[0]);
+ if (pp[0])
+ gcry_md_write (md, pp[0], nn[0]);
}
else
- for(i=0; i < npkey; i++ )
- {
- gcry_md_write ( md, pp[i], nn[i] );
- xfree(pp[i]);
- }
+ {
+ for(i=0; i < npkey; i++ )
+ {
+ if (pp[i])
+ gcry_md_write ( md, pp[i], nn[i] );
+ xfree(pp[i]);
+ }
+ }
}