diff --git a/g10/ChangeLog b/g10/ChangeLog index cb73e2662..99a3d5ccd 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,7 @@ +2004-06-16 Werner Koch + + * free-packet.c (copy_secret_key): Get last fix right. + 2004-06-16 Werner Koch * free-packet.c (copy_secret_key): Fixed memory leak. diff --git a/g10/free-packet.c b/g10/free-packet.c index d5965808c..b9a41ab98 100644 --- a/g10/free-packet.c +++ b/g10/free-packet.c @@ -261,21 +261,15 @@ copy_secret_key( PKT_secret_key *d, PKT_secret_key *s ) if( !d ) d = m_alloc(sizeof *d); + else + release_secret_key_parts (d); 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]); - } + 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] ); - } + d->skey[i] = mpi_copy( s->skey[i] ); } return d;