1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

(copy_secret_key): Fixed memory leak.

This commit is contained in:
Werner Koch 2004-06-16 09:36:59 +00:00
parent 20917c3c30
commit 40e66b1af1
3 changed files with 14 additions and 0 deletions

View file

@ -264,11 +264,20 @@ copy_secret_key( PKT_secret_key *d, PKT_secret_key *s )
memcpy( d, s, sizeof *d );
n = pubkey_get_nskey( s->pubkey_algo );
if( !n )
{
if (d->skey[0])
mpi_free (d->skey[0]);
d->skey[0] = mpi_copy(s->skey[0]);
}
else {
for(i=0; i < n; i++ )
{
if (d->skey[i])
mpi_free (d->skey[i]);
d->skey[i] = mpi_copy( s->skey[i] );
}
}
return d;
}