Skip to content

Commit

Permalink
pkcs15-pubkey.c - no need to test if key is null before free
Browse files Browse the repository at this point in the history
As suggested in comments in OpenSC#3090  simplify code when clearing a pubkey.
Not shown in diff next line is:
 sc_mem_clear(key, sizeof(*key));

 Date:      Thu Mar 28 15:37:32 2024 -0500

 On branch X25519-improvements-2
 Changes to be committed:
	modified:   pkcs15-pubkey.c
  • Loading branch information
dengert committed Apr 17, 2024
1 parent 37a5065 commit b29a2d0
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/libopensc/pkcs15-pubkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -1154,23 +1154,17 @@ sc_pkcs15_erase_pubkey(struct sc_pkcs15_pubkey *key)
}
switch (key->algorithm) {
case SC_ALGORITHM_RSA:
if (key->u.rsa.modulus.data)
free(key->u.rsa.modulus.data);
if (key->u.rsa.exponent.data)
free(key->u.rsa.exponent.data);
break;
case SC_ALGORITHM_GOSTR3410:
if (key->u.gostr3410.xy.data)
free(key->u.gostr3410.xy.data);
break;
case SC_ALGORITHM_EC:
case SC_ALGORITHM_EDDSA:
case SC_ALGORITHM_XEDDSA:
if (key->u.ec.params.der.value)
free(key->u.ec.params.der.value);
if (key->u.ec.params.named_curve)
free(key->u.ec.params.named_curve);
if (key->u.ec.ecpointQ.value)
free(key->u.ec.ecpointQ.value);
break;
}
Expand Down

0 comments on commit b29a2d0

Please sign in to comment.