don't leak memory on pk ops

svn:r117
This commit is contained in:
Roger Dingledine 2002-09-27 22:13:22 +00:00
parent e7ecd5e1d5
commit 2fa4b5bb53

View File

@ -234,10 +234,9 @@ int crypto_pk_read_private_key_from_file(crypto_pk_env_t *env, FILE *src)
switch(env->type) { switch(env->type) {
case CRYPTO_PK_RSA: case CRYPTO_PK_RSA:
/*
if (env->key) if (env->key)
RSA_free((RSA *)env->key);*/ RSA_free((RSA *)env->key);
env->key = (unsigned char *)PEM_read_RSAPrivateKey(src, (RSA **)&env->key, NULL, NULL); env->key = (unsigned char *)PEM_read_RSAPrivateKey(src, NULL, NULL, NULL);
if (!env->key) if (!env->key)
return -1; return -1;
break; break;
@ -298,7 +297,9 @@ int crypto_pk_read_public_key_from_file(crypto_pk_env_t *env, FILE *src)
switch(env->type) { switch(env->type) {
case CRYPTO_PK_RSA: case CRYPTO_PK_RSA:
env->key = (unsigned char *)PEM_read_RSAPublicKey(src, (RSA **)&env->key, NULL, NULL); if(env->key)
RSA_free((RSA *)env->key);
env->key = (unsigned char *)PEM_read_RSAPublicKey(src, NULL, NULL, NULL);
if (!env->key) if (!env->key)
return -1; return -1;
break; break;